Skip to content

Commit 5269c95

Browse files
authored
Merge pull request NginxProxyManager#1085 from jc21/improved-new-password-error-messages
Improved new password error messages
2 parents 8461aca + 899b487 commit 5269c95

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

frontend/js/app/user/password.ejs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<button type="button" class="close cancel" aria-label="Close" data-dismiss="modal">&nbsp;</button>
55
</div>
66
<div class="modal-body">
7+
<div class="alert alert-danger" id="error-info" role="alert"></div>
78
<form>
89
<% if (isSelf()) { %>
910
<div class="form-group">
@@ -15,7 +16,7 @@
1516
<div class="form-group">
1617
<label class="form-label"><%- i18n('users', 'new-password') %></label>
1718
<input type="password" name="new_password1" class="form-control" placeholder="" minlength="8" required>
18-
<div class="invalid-feedback secret-error"></div>
19+
<div class="invalid-feedback new-secret-error"></div>
1920
</div>
2021
<div class="form-group">
2122
<label class="form-label"><%- i18n('users', 'confirm-password') %></label>

frontend/js/app/user/password.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@ module.exports = Mn.View.extend({
99
className: 'modal-dialog',
1010

1111
ui: {
12-
form: 'form',
13-
buttons: '.modal-footer button',
14-
cancel: 'button.cancel',
15-
save: 'button.save',
16-
error: '.secret-error'
12+
form: 'form',
13+
buttons: '.modal-footer button',
14+
cancel: 'button.cancel',
15+
save: 'button.save',
16+
newSecretError: '.new-secret-error',
17+
generalError: '#error-info',
1718
},
1819

1920
events: {
2021
'click @ui.save': function (e) {
2122
e.preventDefault();
22-
this.ui.error.hide();
23+
this.ui.newSecretError.hide();
24+
this.ui.generalError.hide();
2325
let form = this.ui.form.serializeJSON();
2426

2527
if (form.new_password1 !== form.new_password2) {
26-
this.ui.error.text('Passwords do not match!').show();
28+
this.ui.newSecretError.text('Passwords do not match!').show();
2729
return;
2830
}
2931

@@ -40,7 +42,11 @@ module.exports = Mn.View.extend({
4042
App.Controller.showUsers();
4143
})
4244
.catch(err => {
43-
this.ui.error.text(err.message).show();
45+
// Change error message to make it a little clearer
46+
if (err.message === 'Invalid password') {
47+
err.message = 'Current password is invalid';
48+
}
49+
this.ui.generalError.text(err.message).show();
4450
this.ui.buttons.prop('disabled', false).removeClass('btn-disabled');
4551
});
4652
}
@@ -54,5 +60,10 @@ module.exports = Mn.View.extend({
5460
return {
5561
isSelf: this.isSelf.bind(this)
5662
};
57-
}
63+
},
64+
65+
onRender: function () {
66+
this.ui.newSecretError.hide();
67+
this.ui.generalError.hide();
68+
},
5869
});

0 commit comments

Comments
 (0)