2019-05-29 05:21:06 -04:00
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Sanity-check the conversion and remove this comment.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2019-09-24 04:44:13 -04:00
|
|
|
const UserMembershipMiddleware = require('./UserMembershipMiddleware')
|
2019-05-29 05:21:06 -04:00
|
|
|
const UserMembershipController = require('./UserMembershipController')
|
|
|
|
const SubscriptionGroupController = require('../Subscription/SubscriptionGroupController')
|
|
|
|
const TeamInvitesController = require('../Subscription/TeamInvitesController')
|
|
|
|
const RateLimiterMiddleware = require('../Security/RateLimiterMiddleware')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
apply(webRouter) {
|
|
|
|
// group members routes
|
|
|
|
webRouter.get(
|
|
|
|
'/manage/groups/:id/members',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.index
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/manage/groups/:id/invites',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'create-team-invite',
|
2020-05-18 05:17:30 -04:00
|
|
|
maxRequests: 200,
|
2019-05-29 05:21:06 -04:00
|
|
|
timeInterval: 60
|
|
|
|
}),
|
|
|
|
TeamInvitesController.createInvite
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/manage/groups/:id/user/:user_id',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
SubscriptionGroupController.removeUserFromGroup
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/manage/groups/:id/invites/:email',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
TeamInvitesController.revokeInvite
|
|
|
|
)
|
|
|
|
webRouter.get(
|
|
|
|
'/manage/groups/:id/members/export',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
RateLimiterMiddleware.rateLimit({
|
|
|
|
endpointName: 'export-team-csv',
|
|
|
|
maxRequests: 30,
|
|
|
|
timeInterval: 60
|
|
|
|
}),
|
|
|
|
UserMembershipController.exportCsv
|
|
|
|
)
|
|
|
|
|
|
|
|
// group managers routes
|
|
|
|
webRouter.get(
|
|
|
|
'/manage/groups/:id/managers',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagersManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.index
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/manage/groups/:id/managers',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagersManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.add
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/manage/groups/:id/managers/:userId',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireGroupManagersManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.remove
|
|
|
|
)
|
|
|
|
|
|
|
|
// institution members routes
|
|
|
|
webRouter.get(
|
|
|
|
'/manage/institutions/:id/managers',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireInstitutionManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.index
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/manage/institutions/:id/managers',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireInstitutionManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.add
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/manage/institutions/:id/managers/:userId',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requireInstitutionManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.remove
|
|
|
|
)
|
|
|
|
|
|
|
|
// publisher members routes
|
|
|
|
webRouter.get(
|
|
|
|
'/manage/publishers/:id/managers',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requirePublisherManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.index
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/manage/publishers/:id/managers',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requirePublisherManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.add
|
|
|
|
)
|
|
|
|
webRouter.delete(
|
|
|
|
'/manage/publishers/:id/managers/:userId',
|
2019-09-24 04:44:13 -04:00
|
|
|
UserMembershipMiddleware.requirePublisherManagementAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.remove
|
|
|
|
)
|
|
|
|
|
2019-09-24 04:44:13 -04:00
|
|
|
// publisher creation routes
|
2019-05-29 05:21:06 -04:00
|
|
|
webRouter.get(
|
2019-09-24 04:44:13 -04:00
|
|
|
'/entities/publisher/create/:id',
|
|
|
|
UserMembershipMiddleware.requirePublisherCreationAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.new
|
|
|
|
)
|
2019-09-24 04:44:13 -04:00
|
|
|
webRouter.post(
|
|
|
|
'/entities/publisher/create/:id',
|
|
|
|
UserMembershipMiddleware.requirePublisherCreationAccess,
|
|
|
|
UserMembershipController.create
|
|
|
|
)
|
|
|
|
|
|
|
|
// institution creation routes
|
|
|
|
webRouter.get(
|
|
|
|
'/entities/institution/create/:id',
|
|
|
|
UserMembershipMiddleware.requireInstitutionCreationAccess,
|
|
|
|
UserMembershipController.new
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/entities/institution/create/:id',
|
|
|
|
UserMembershipMiddleware.requireInstitutionCreationAccess,
|
2019-05-29 05:21:06 -04:00
|
|
|
UserMembershipController.create
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|