mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
hooked up password reset to use new email sending
This commit is contained in:
parent
3c18cc5553
commit
8ba1a08245
3 changed files with 14 additions and 15 deletions
|
@ -46,7 +46,7 @@ templates.passwordReset =
|
|||
compiledTemplate: _.template '''
|
||||
<h1 class="h1">Password Reset</h1>
|
||||
<p>
|
||||
Your password has been reset, the new password is <p> {{newPassword}}:
|
||||
Your password has been reset, the new password is <p> {{newPassword}}
|
||||
<p>
|
||||
please <a href="https://www.sharelatex.com/login">login here</a> and then change your password <a href=#{Settings.siteUrl}/user/settings> in your user settings</a>
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ Settings = require('settings-sharelatex')
|
|||
metrics = require("../../infrastructure/Metrics")
|
||||
ses = require('node-ses')
|
||||
|
||||
|
||||
if Settings.email?.ses? and Settings.email.ses?.key? and Settings.email.ses?.key != "" and Settings.email.ses?.secret? and Settings.email.ses?.secret != ""
|
||||
client = ses.createClient({ key: Settings.email.ses.key, secret: Settings.email.ses.secret });
|
||||
else
|
||||
|
|
|
@ -2,7 +2,6 @@ User = require('../models/User').User
|
|||
sanitize = require('validator').sanitize
|
||||
fs = require('fs')
|
||||
_ = require('underscore')
|
||||
emailer = require('../managers/EmailManager')
|
||||
logger = require('logger-sharelatex')
|
||||
Security = require('../managers/SecurityManager')
|
||||
Settings = require('settings-sharelatex')
|
||||
|
@ -16,6 +15,7 @@ AuthenticationManager = require("../Features/Authentication/AuthenticationManage
|
|||
AuthenticationController = require("../Features/Authentication/AuthenticationController")
|
||||
SubscriptionLocator = require("../Features/Subscription/SubscriptionLocator")
|
||||
UserDeleter = require("../Features/User/UserDeleter")
|
||||
EmailHandler = require("../Features/Email/EmailHandler")
|
||||
Url = require("url")
|
||||
|
||||
module.exports =
|
||||
|
@ -100,19 +100,17 @@ module.exports =
|
|||
if(user?)
|
||||
randomPassword = generateRandomString 12
|
||||
AuthenticationManager.setUserPassword user._id, randomPassword, (error) ->
|
||||
return next(error) if error?
|
||||
emailOptions =
|
||||
receiver : user.email
|
||||
subject : "Password Reset - ShareLatex.com"
|
||||
heading : "Password Reset"
|
||||
message : " Your password has been reset, the new password is <p> #{randomPassword}
|
||||
<p> please login <a href=#{Settings.siteUrl}/user/settings>click here</a>
|
||||
"
|
||||
emailer.sendEmail emailOptions
|
||||
metrics.inc "user.password-reset"
|
||||
res.send message:
|
||||
text:'An email with your new password has been sent to you'
|
||||
type:'success'
|
||||
emailOpts =
|
||||
newPassword: randomPassword
|
||||
to: user.email
|
||||
EmailHandler.sendEmail "passwordReset", emailOpts, (err)->
|
||||
if err?
|
||||
logger.err err:err, emailOpts:emailOpts, "problem sending password reset email"
|
||||
return res.send 500
|
||||
metrics.inc "user.password-reset"
|
||||
res.send message:
|
||||
text:'An email with your new password has been sent to you'
|
||||
type:'success'
|
||||
else
|
||||
res.send message:
|
||||
text:'This email address has not been registered with us'
|
||||
|
|
Loading…
Reference in a new issue