mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Move add email function
GitOrigin-RevId: f45e28a9ed357427ae606ad5f8b59acaef54e31b
This commit is contained in:
parent
5c918bed94
commit
de8ac8ace7
1 changed files with 30 additions and 30 deletions
|
@ -9,6 +9,35 @@ const logger = require('logger-sharelatex')
|
||||||
const Errors = require('../Errors/Errors')
|
const Errors = require('../Errors/Errors')
|
||||||
const HttpErrors = require('@overleaf/o-error/http')
|
const HttpErrors = require('@overleaf/o-error/http')
|
||||||
|
|
||||||
|
function add(req, res, next) {
|
||||||
|
const userId = AuthenticationController.getLoggedInUserId(req)
|
||||||
|
const email = EmailHelper.parseEmail(req.body.email)
|
||||||
|
if (!email) {
|
||||||
|
return res.sendStatus(422)
|
||||||
|
}
|
||||||
|
|
||||||
|
const affiliationOptions = {
|
||||||
|
university: req.body.university,
|
||||||
|
role: req.body.role,
|
||||||
|
department: req.body.department
|
||||||
|
}
|
||||||
|
UserUpdater.addEmailAddress(userId, email, affiliationOptions, function(
|
||||||
|
error
|
||||||
|
) {
|
||||||
|
if (error) {
|
||||||
|
return UserEmailsController._handleEmailError(error, req, res, next)
|
||||||
|
}
|
||||||
|
UserEmailsConfirmationHandler.sendConfirmationEmail(userId, email, function(
|
||||||
|
error
|
||||||
|
) {
|
||||||
|
if (error) {
|
||||||
|
return next(error)
|
||||||
|
}
|
||||||
|
res.sendStatus(204)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = UserEmailsController = {
|
module.exports = UserEmailsController = {
|
||||||
list(req, res, next) {
|
list(req, res, next) {
|
||||||
const userId = AuthenticationController.getLoggedInUserId(req)
|
const userId = AuthenticationController.getLoggedInUserId(req)
|
||||||
|
@ -20,36 +49,7 @@ module.exports = UserEmailsController = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
add(req, res, next) {
|
add,
|
||||||
const userId = AuthenticationController.getLoggedInUserId(req)
|
|
||||||
const email = EmailHelper.parseEmail(req.body.email)
|
|
||||||
if (!email) {
|
|
||||||
return res.sendStatus(422)
|
|
||||||
}
|
|
||||||
|
|
||||||
const affiliationOptions = {
|
|
||||||
university: req.body.university,
|
|
||||||
role: req.body.role,
|
|
||||||
department: req.body.department
|
|
||||||
}
|
|
||||||
UserUpdater.addEmailAddress(userId, email, affiliationOptions, function(
|
|
||||||
error
|
|
||||||
) {
|
|
||||||
if (error) {
|
|
||||||
return UserEmailsController._handleEmailError(error, req, res, next)
|
|
||||||
}
|
|
||||||
UserEmailsConfirmationHandler.sendConfirmationEmail(
|
|
||||||
userId,
|
|
||||||
email,
|
|
||||||
function(error) {
|
|
||||||
if (error) {
|
|
||||||
return next(error)
|
|
||||||
}
|
|
||||||
res.sendStatus(204)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
remove(req, res, next) {
|
remove(req, res, next) {
|
||||||
const userId = AuthenticationController.getLoggedInUserId(req)
|
const userId = AuthenticationController.getLoggedInUserId(req)
|
||||||
|
|
Loading…
Reference in a new issue