mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-28 03:10:49 +00:00
15 lines
No EOL
687 B
CoffeeScript
15 lines
No EOL
687 B
CoffeeScript
module.exports = AuthorizationManager =
|
|
assertClientCanViewProject: (client, callback = (error) ->) ->
|
|
AuthorizationManager._assertClientHasPrivilegeLevel client, ["readOnly", "readAndWrite", "owner"], callback
|
|
|
|
assertClientCanEditProject: (client, callback = (error) ->) ->
|
|
AuthorizationManager._assertClientHasPrivilegeLevel client, ["readAndWrite", "owner"], callback
|
|
|
|
_assertClientHasPrivilegeLevel: (client, allowedLevels, callback = (error) ->) ->
|
|
client.get "privilege_level", (error, privilegeLevel) ->
|
|
return callback(error) if error?
|
|
allowed = (privilegeLevel in allowedLevels)
|
|
if allowed
|
|
callback null
|
|
else
|
|
callback new Error("not authorized") |