2021-11-10 08:40:18 -05:00
|
|
|
const logger = require('@overleaf/logger')
|
2020-07-15 06:46:32 -04:00
|
|
|
const UserActivateController = require('./UserActivateController')
|
|
|
|
const AuthenticationController = require('../../../../app/src/Features/Authentication/AuthenticationController')
|
2022-04-07 09:41:05 -04:00
|
|
|
const AuthorizationMiddleware = require('../../../../app/src/Features/Authorization/AuthorizationMiddleware')
|
2020-07-15 06:46:32 -04:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
apply(webRouter) {
|
2022-05-16 08:38:18 -04:00
|
|
|
logger.debug({}, 'Init UserActivate router')
|
2020-07-15 06:46:32 -04:00
|
|
|
|
2022-04-07 09:41:05 -04:00
|
|
|
webRouter.get(
|
|
|
|
'/admin/user',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
(req, res) => res.redirect('/admin/register')
|
|
|
|
)
|
|
|
|
|
2020-07-15 06:46:32 -04:00
|
|
|
webRouter.get('/user/activate', UserActivateController.activateAccountPage)
|
|
|
|
AuthenticationController.addEndpointToLoginWhitelist('/user/activate')
|
2022-04-07 09:41:05 -04:00
|
|
|
|
|
|
|
webRouter.get(
|
|
|
|
'/admin/register',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
UserActivateController.registerNewUser
|
|
|
|
)
|
|
|
|
webRouter.post(
|
|
|
|
'/admin/register',
|
|
|
|
AuthorizationMiddleware.ensureUserIsSiteAdmin,
|
|
|
|
UserActivateController.register
|
|
|
|
)
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2020-07-15 06:46:32 -04:00
|
|
|
}
|