diff --git a/public/javascripts/spacedeck_users.js b/public/javascripts/spacedeck_users.js index 1b62363..7f2a9ad 100644 --- a/public/javascripts/spacedeck_users.js +++ b/public/javascripts/spacedeck_users.js @@ -196,27 +196,29 @@ SpacedeckUsers = { this.password_reset_confirm_error = null; this.password_reset_send = false; - if(password != password_confirmation) { + if (password != password_confirmation) { this.password_reset_confirm_error = "Passwords do not match."; return; } - if(password.length < 5) { + if (password.length < 5) { this.password_reset_confirm_error = "Password too short (must have at least 5 characters)."; return; } confirm_password_reset(password, this.reset_token, function(parsed,req) { - if(req.status==201){ + if (req.status==201) { + alert("New password set successfully."); this.active_view = "login"; + } else { + alert("An unknown error occured."); } }.bind(this), function(req) { if (req.status==404) { - var msg = "user not found"; + alert("Error: Unknown user."); } else { - var msg = "error: " + req.statusText; + alert("Error: "+req.statusText); } - this.password_reset_confirm_error = msg; }.bind(this)); }, diff --git a/routes/api/users.js b/routes/api/users.js index 187b925..99ba793 100644 --- a/routes/api/users.js +++ b/routes/api/users.js @@ -289,15 +289,10 @@ router.post('/password_reset_requests/:confirm_token/confirm', function(req, res if (user) { bcrypt.genSalt(10, (err, salt) => { bcrypt.hash(password, salt, function(err, hash) { - user.password_hash = hash; user.password_token = null; - user.save(function(err, updatedUser){ - if (err) { - res.sendStatus(400); - } else { - res.sendStatus(201); - } + user.save().then(function(updatedUser) { + res.sendStatus(201); }); }); }); diff --git a/views/partials/login.html b/views/partials/login.html index a0c80c7..de19912 100644 --- a/views/partials/login.html +++ b/views/partials/login.html @@ -57,7 +57,7 @@
- +
@@ -98,8 +98,8 @@
-

[[__("password_confirmation")]]

- [[__("password_check_inbox")]] +

Reset Password

+ Please check your email inbox.
@@ -110,11 +110,11 @@
- +
- +