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

41 lines
1.7 KiB
CoffeeScript
Raw Normal View History

UserMembershipAuthorization = require './UserMembershipAuthorization'
2018-09-25 09:10:06 -04:00
UserMembershipController = require './UserMembershipController'
SubscriptionGroupController = require '../Subscription/SubscriptionGroupController'
TeamInvitesController = require '../Subscription/TeamInvitesController'
2018-09-25 09:10:06 -04:00
module.exports =
apply: (webRouter) ->
2018-10-11 13:56:14 -04:00
webRouter.get '/manage/groups/:id/members',
UserMembershipAuthorization.requireEntityAccess('group'),
UserMembershipController.index
webRouter.post '/manage/groups/:id/invites',
UserMembershipAuthorization.requireEntityAccess('group'),
TeamInvitesController.createInvite
webRouter.delete '/manage/groups/:id/user/:user_id',
UserMembershipAuthorization.requireEntityAccess('group'),
SubscriptionGroupController.removeUserFromGroup
webRouter.delete '/manage/groups/:id/invites/:email',
UserMembershipAuthorization.requireEntityAccess('group'),
TeamInvitesController.revokeInvite
webRouter.get '/manage/groups/:id/members/export',
UserMembershipAuthorization.requireEntityAccess('group'),
UserMembershipController.exportCsv
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