mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
24 lines
983 B
CoffeeScript
24 lines
983 B
CoffeeScript
WebApiManager = require "../WebApi/WebApiManager"
|
|
SocketManager = require "../Sockets/SocketManager"
|
|
|
|
module.exports = AuthorizationManager =
|
|
canClientJoinProjectRoom: (client, project_id, callback = (error, authorized) ->) ->
|
|
client.get "auth_token", (error, auth_token) ->
|
|
return callback(error) if error?
|
|
WebApiManager.getProjectCollaborators project_id, auth_token, (error, collaborators) ->
|
|
return callback(error) if error?
|
|
client.get "id", (error, user_id) ->
|
|
return callback(error) if error?
|
|
authorized = false
|
|
for collaborator in collaborators
|
|
if collaborator.id == user_id
|
|
authorized = true
|
|
break
|
|
callback null, authorized
|
|
|
|
canClientSendMessageToRoom: (client, room_id, callback = (error, authorized) ->) ->
|
|
SocketManager.isClientInRoom(client, room_id, callback)
|
|
|
|
canClientReadMessagesInRoom: (client, room_id, callback = (error, authorized) ->) ->
|
|
SocketManager.isClientInRoom(client, room_id, callback)
|
|
|