mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Just generate a new token on resending confirmation email
This commit is contained in:
@@ -27,16 +27,6 @@ module.exports =
|
||||
return callback(error) if error?
|
||||
callback null, token
|
||||
|
||||
findValidTokenFromData: (use, data, callback = (error, token) ->) ->
|
||||
db.tokens.findOne {
|
||||
use: use,
|
||||
data: data,
|
||||
expiresAt: { $gt: new Date() },
|
||||
usedAt: { $exists: false }
|
||||
}, (error, token) ->
|
||||
return callback(error) if error?
|
||||
return callback null, token?.token
|
||||
|
||||
getValueFromTokenAndExpire: (use, token, callback = (error, data) ->)->
|
||||
logger.log token_start: token.slice(0,8), "getting data from #{use} token"
|
||||
now = new Date()
|
||||
|
||||
@@ -23,17 +23,6 @@ module.exports = UserEmailsConfirmationHandler =
|
||||
confirmEmailUrl: "#{settings.siteUrl}/user/emails/confirm?token=#{token}"
|
||||
EmailHandler.sendEmail emailTemplate, emailOptions, callback
|
||||
|
||||
resendConfirmationEmail: (user_id, email, callback = (error) ->) ->
|
||||
OneTimeTokenHandler.findValidTokenFromData 'email_confirmation', { user_id, email }, (error, token) ->
|
||||
return callback(error) if error?
|
||||
if !token?
|
||||
UserEmailsConfirmationHandler.sendConfirmationEmail user_id, email, callback
|
||||
else
|
||||
emailOptions =
|
||||
to: email
|
||||
confirmEmailUrl: "#{settings.siteUrl}/user/emails/confirm?token=#{token}"
|
||||
EmailHandler.sendEmail 'confirmEmail', emailOptions, callback
|
||||
|
||||
confirmEmailFromToken: (token, callback = (error) ->) ->
|
||||
logger.log {token_start: token.slice(0,8)}, 'confirming email from token'
|
||||
OneTimeTokenHandler.getValueFromTokenAndExpire 'email_confirmation', token, (error, data) ->
|
||||
|
||||
@@ -71,7 +71,7 @@ module.exports = UserEmailsController =
|
||||
logger.log {userId, email, foundUserId: user?._id}, "email doesn't match logged in user"
|
||||
return res.sendStatus 422
|
||||
logger.log {userId, email}, 'resending email confirmation token'
|
||||
UserEmailsConfirmationHandler.resendConfirmationEmail userId, email, (error) ->
|
||||
UserEmailsConfirmationHandler.sendConfirmationEmail userId, email, (error) ->
|
||||
return next(error) if error?
|
||||
res.sendStatus 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user