|
|
@@ -1,7 +1,5 @@
|
|
|
let UserEmailsController
|
|
|
const AuthenticationController = require('../Authentication/AuthenticationController')
|
|
|
-const Features = require('../../infrastructure/Features')
|
|
|
-const InstitutionsAPI = require('../Institutions/InstitutionsAPI')
|
|
|
const UserGetter = require('./UserGetter')
|
|
|
const UserUpdater = require('./UserUpdater')
|
|
|
const EmailHelper = require('../Helpers/EmailHelper')
|
|
|
@@ -40,13 +38,13 @@ function add(req, res, next) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-async function resendConfirmation(req, res, next) {
|
|
|
+function resendConfirmation(req, res, next) {
|
|
|
const userId = AuthenticationController.getLoggedInUserId(req)
|
|
|
const email = EmailHelper.parseEmail(req.body.email)
|
|
|
if (!email) {
|
|
|
return res.sendStatus(422)
|
|
|
}
|
|
|
- UserGetter.getUserByAnyEmail(email, { _id: 1 }, async function(error, user) {
|
|
|
+ UserGetter.getUserByAnyEmail(email, { _id: 1 }, function(error, user) {
|
|
|
if (error) {
|
|
|
return next(error)
|
|
|
}
|
|
|
@@ -57,23 +55,6 @@ async function resendConfirmation(req, res, next) {
|
|
|
)
|
|
|
return res.sendStatus(422)
|
|
|
}
|
|
|
- if (Features.hasFeature('saml') || req.session.samlBeta) {
|
|
|
- // institution SSO emails cannot be confirmed by email,
|
|
|
- // confirmation happens by linking to the institution
|
|
|
- let institution
|
|
|
- try {
|
|
|
- institution = await InstitutionsAPI.getInstitutionViaDomain(
|
|
|
- email.split('@').pop()
|
|
|
- )
|
|
|
- } catch (error) {
|
|
|
- if (!(error instanceof Errors.NotFoundError)) {
|
|
|
- throw error
|
|
|
- }
|
|
|
- }
|
|
|
- if (institution && institution.sso_enabled) {
|
|
|
- return res.sendStatus(422)
|
|
|
- }
|
|
|
- }
|
|
|
logger.log({ userId, email }, 'resending email confirmation token')
|
|
|
UserEmailsConfirmationHandler.sendConfirmationEmail(userId, email, function(
|
|
|
error
|