overleaf/services/web/app/coffee/Features/UserMembership/UserMembershipRouter.coffee
Timothée Alby b123f830ff Merge pull request #1042 from sharelatex/ta-user-membership-access
User Membership Access Refactor

GitOrigin-RevId: 23e8d342bc4829450625146213ff92cb042550dd
2018-10-24 14:02:55 +00:00

26 lines
957 B
CoffeeScript

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