Move admin register to user activate module

Move admin register to user activate module

Co-authored-by: John Lees-Miller <jdleesmiller@gmail.com> & Davinder Singh
GitOrigin-RevId: 79428f2932783086435bdad9b1efb5300c467511
This commit is contained in:
Davinder Singh
2022-04-07 14:41:05 +01:00
committed by Copybot
parent bce02b25e4
commit b3d55fa65e
8 changed files with 77 additions and 70 deletions
@@ -1,8 +1,32 @@
const Path = require('path')
const UserGetter = require('../../../../app/src/Features/User/UserGetter')
const UserRegistrationHandler = require('../../../../app/src/Features/User/UserRegistrationHandler')
const ErrorController = require('../../../../app/src/Features/Errors/ErrorController')
module.exports = {
registerNewUser(req, res, next) {
res.render(Path.resolve(__dirname, '../views/user/register'))
},
register(req, res, next) {
const { email } = req.body
if (email == null || email === '') {
return res.sendStatus(422) // Unprocessable Entity
}
UserRegistrationHandler.registerNewUserAndSendActivationEmail(
email,
(error, user, setNewPasswordUrl) => {
if (error != null) {
return next(error)
}
res.json({
email: user.email,
setNewPasswordUrl,
})
}
)
},
activateAccountPage(req, res, next) {
// An 'activation' is actually just a password reset on an account that
// was set with a random password originally.