mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Tidy up callbacks
This commit is contained in:
parent
7b33f8b4c2
commit
b6c2a8f7f7
1 changed files with 4 additions and 10 deletions
|
@ -8,17 +8,13 @@ module.exports = TokenAccessHandler =
|
|||
Project.findOne {
|
||||
'tokens.readOnly': token,
|
||||
'publicAccesLevel': PublicAccessLevels.TOKEN_BASED
|
||||
}, {_id: 1, publicAccesLevel: 1}, (err, project) ->
|
||||
return callback(err) if err?
|
||||
callback(null, project)
|
||||
}, {_id: 1, publicAccesLevel: 1}, callback
|
||||
|
||||
findProjectWithReadAndWriteToken: (token, callback=(err, project)->) ->
|
||||
Project.findOne {
|
||||
'tokens.readAndWrite': token,
|
||||
'publicAccesLevel': PublicAccessLevels.TOKEN_BASED
|
||||
}, {_id: 1, publicAccesLevel: 1}, (err, project) ->
|
||||
return callback(err) if err?
|
||||
callback(null, project)
|
||||
}, {_id: 1, publicAccesLevel: 1}, callback
|
||||
|
||||
addReadOnlyUserToProject: (userId, projectId, callback=(err)->) ->
|
||||
userId = ObjectId(userId.toString())
|
||||
|
@ -27,8 +23,7 @@ module.exports = TokenAccessHandler =
|
|||
_id: projectId
|
||||
}, {
|
||||
$addToSet: {tokenAccessReadOnly_refs: userId}
|
||||
}, (err) ->
|
||||
callback(err)
|
||||
}, callback
|
||||
|
||||
addReadAndWriteUserToProject: (userId, projectId, callback=(err)->) ->
|
||||
userId = ObjectId(userId.toString())
|
||||
|
@ -37,8 +32,7 @@ module.exports = TokenAccessHandler =
|
|||
_id: projectId
|
||||
}, {
|
||||
$addToSet: {tokenAccessReadAndWrite_refs: userId}
|
||||
}, (err) ->
|
||||
callback(err)
|
||||
}, callback
|
||||
|
||||
grantSessionReadOnlyTokenAccess: (req, projectId, token) ->
|
||||
if req.session?
|
||||
|
|
Loading…
Reference in a new issue