fix password recovery

This commit is contained in:
mntmn 2020-04-09 22:21:55 +02:00
parent f5a6adc43b
commit a92b915bc3
3 changed files with 15 additions and 18 deletions

View File

@ -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));
},

View File

@ -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);
});
});
});

View File

@ -57,7 +57,7 @@
</div>
<div class="form-group">
<input class="input" id="user-password-confirmation" required type="password" v-model="signup_password_confirmation" placeholder="[[__("password_confirmation")]]">
<input class="input" id="user-password-confirmation" required type="password" v-model="signup_password_confirmation" placeholder="Repeat Password">
</div>
</div>
@ -98,8 +98,8 @@
</form>
</div>
<div class="content" v-if="password_reset_send==true">
<h4>[[__("password_confirmation")]]</h4>
[[__("password_check_inbox")]]
<h4>Reset Password</h4>
Please check your email inbox.
</div>
</div>
@ -110,11 +110,11 @@
<div class="tight">
<div class="form-group">
<input class="input" id="user-password" type="password" v-model="signup_password" placeholder="[[__("password")]]">
<input class="input" id="user-password" type="password" v-model="signup_password" placeholder="New Password">
</div>
<div class="form-group">
<input class="input" id="user-password" type="password" v-model="signup_password_confirmation" placeholder="[[__("password_confirmation")]]">
<input class="input" id="user-password" type="password" v-model="signup_password_confirmation" placeholder="Repeat Password">
</div>
</div>