overleaf/services/web/app/coffee/Features/PasswordReset/PasswordResetController.coffee

31 lines
748 B
CoffeeScript
Raw Normal View History

2014-05-15 11:50:38 -04:00
PasswordResetHandler = require("./PasswordResetHandler")
2014-05-15 11:20:23 -04:00
module.exports =
2014-05-15 11:50:38 -04:00
renderRequestResetForm: (req, res)->
res.render "user/passwordReset",
title:"Reset Password"
2014-05-15 11:20:23 -04:00
2014-05-15 11:50:38 -04:00
requestReset: (req, res)->
email = req.body.email.trim()
PasswordResetHandler.generateAndEmailResetToken email, (err)->
if err?
res.send 500
else
res.send 200
2014-05-15 11:20:23 -04:00
2014-05-15 11:50:38 -04:00
renderSetPasswordForm: (req, res)->
res.render "user/setPassword",
title:"Set Password"
2014-05-15 11:20:23 -04:00
2014-05-15 11:50:38 -04:00
setNewUserPassword: (req, res)->
{token, password} = req.body
if !password? or password.length < 4 or !token? or token.length == 0
return res.send 500
PasswordResetHandler.setNewUserPassword token?.trim(), password?.trim(), (err)->
if err?
res.send 500
else
res.send 200