Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Labels
Plan
Issues
25
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cokoapps
server
Commits
877f428e
Commit
877f428e
authored
2 years ago
by
Yannis Barlas
Browse files
Options
Downloads
Patches
Plain Diff
fix(middleware): permissions circular dependency
parent
1aac7069
No related branches found
No related tags found
2 merge requests
!52
Docx
,
!17
Graphql api
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
authorization.js
+14
-1
14 additions, 1 deletion
authorization.js
src/helpers.js
+0
-18
0 additions, 18 deletions
src/helpers.js
with
14 additions
and
19 deletions
authorization.js
+
14
−
1
View file @
877f428e
...
...
@@ -9,7 +9,20 @@ const {
not
,
}
=
require
(
'
graphql-shield
'
)
const
{
isAdmin
,
isAuthenticated
}
=
require
(
'
./src/helpers
'
)
const
isAuthenticated
=
rule
()(
async
(
parent
,
args
,
ctx
,
info
)
=>
{
return
!!
ctx
.
user
})
const
isAdmin
=
rule
()(
async
(
parent
,
args
,
{
user
:
userId
,
connectors
:
{
User
}
},
info
)
=>
{
if
(
!
userId
)
{
return
false
}
const
user
=
await
User
.
model
.
findById
(
userId
)
return
user
.
admin
},
)
module
.
exports
=
{
rule
,
...
...
This diff is collapsed.
Click to expand it.
src/helpers.js
+
0
−
18
View file @
877f428e
// const axios = require('axios')
const
{
rule
}
=
require
(
'
graphql-shield
'
)
const
path
=
require
(
'
path
'
)
const
sharp
=
require
(
'
sharp
'
)
const
fs
=
require
(
'
fs-extra
'
)
...
...
@@ -10,21 +9,6 @@ const fs = require('fs-extra')
// const services = config.get('services')
const
isAuthenticated
=
rule
()(
async
(
parent
,
args
,
ctx
,
info
)
=>
{
return
!!
ctx
.
user
})
const
isAdmin
=
rule
()(
async
(
parent
,
args
,
{
user
:
userId
,
connectors
:
{
User
}
},
info
)
=>
{
if
(
!
userId
)
{
return
false
}
const
user
=
await
User
.
model
.
findById
(
userId
)
return
user
.
admin
},
)
const
convertFileStreamIntoBuffer
=
async
fileStream
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
// Store file data chunks
...
...
@@ -172,8 +156,6 @@ const writeFileFromStream = async (inputStream, filePath) => {
// }
module
.
exports
=
{
isAuthenticated
,
isAdmin
,
convertFileStreamIntoBuffer
,
getFileExtension
,
getImageFileMetadata
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment