overleaf/services/web/modules/user-activate/app/src/UserActivateRouter.mjs
Miguel Serrano b290510faf Merge pull request #21394 from overleaf/msm-esm-user-activation
[web] Migrate `modules/user-activate` to ESM

GitOrigin-RevId: e5ab3e9c53ea2d3f4ddfbc2200a889b8bb0db83c
2024-10-29 09:05:25 +00:00

30 lines
1,017 B
JavaScript

import logger from '@overleaf/logger'
import UserActivateController from './UserActivateController.mjs'
import AuthenticationController from '../../../../app/src/Features/Authentication/AuthenticationController.js'
import AuthorizationMiddleware from '../../../../app/src/Features/Authorization/AuthorizationMiddleware.js'
export default {
apply(webRouter) {
logger.debug({}, 'Init UserActivate router')
webRouter.get(
'/admin/user',
AuthorizationMiddleware.ensureUserIsSiteAdmin,
(req, res) => res.redirect('/admin/register')
)
webRouter.get('/user/activate', UserActivateController.activateAccountPage)
AuthenticationController.addEndpointToLoginWhitelist('/user/activate')
webRouter.get(
'/admin/register',
AuthorizationMiddleware.ensureUserIsSiteAdmin,
UserActivateController.registerNewUser
)
webRouter.post(
'/admin/register',
AuthorizationMiddleware.ensureUserIsSiteAdmin,
UserActivateController.register
)
},
}