overleaf/services/web/app/coffee/Features/UserMembership/UserMembershipRouter.coffee

27 lines
957 B
CoffeeScript
Raw Normal View History

UserMembershipAuthorization = require './UserMembershipAuthorization'
2018-09-25 09:10:06 -04:00
UserMembershipController = require './UserMembershipController'
module.exports =
apply: (webRouter) ->
2018-10-11 13:56:14 -04:00
webRouter.get '/manage/groups/:id/members',
UserMembershipAuthorization.requireEntityAccess('group'),
UserMembershipController.index
2018-09-25 09:10:06 -04:00
regularEntitites =
2018-10-11 13:56:14 -04:00
groups: 'groupManagers'
institutions: 'institution'
2018-09-25 09:10:06 -04:00
for pathName, entityName of regularEntitites
do (pathName, entityName) ->
2018-10-11 13:56:14 -04:00
webRouter.get "/manage/#{pathName}/:id/managers",
UserMembershipAuthorization.requireEntityAccess(entityName),
UserMembershipController.index
2018-09-25 09:10:06 -04:00
2018-10-11 13:56:14 -04:00
webRouter.post "/manage/#{pathName}/:id/managers",
UserMembershipAuthorization.requireEntityAccess(entityName),
UserMembershipController.add
2018-09-25 09:10:06 -04:00
2018-10-11 13:56:14 -04:00
webRouter.delete "/manage/#{pathName}/:id/managers/:userId",
UserMembershipAuthorization.requireEntityAccess(entityName),
UserMembershipController.remove