Fixed bug with password form

This commit is contained in:
Wyatt Johnson
2018-05-07 17:47:02 -06:00
parent 926364ad72
commit 10a99aab88
4 changed files with 18 additions and 5 deletions
+9
View File
@@ -371,6 +371,14 @@ class ErrParentDoesNotVisible extends TalkError {
}
}
class ErrPasswordIncorrect extends TalkError {
constructor() {
super('Your current password was entered incorrectly', {
translation_key: 'PASSWORD_INCORRECT',
});
}
}
module.exports = {
TalkError,
ErrAlreadyExists,
@@ -395,6 +403,7 @@ module.exports = {
ErrNotFound,
ErrNotVerified,
ErrParentDoesNotVisible,
ErrPasswordIncorrect,
ErrPasswordResetToken,
ErrPasswordTooShort,
ErrPermissionUpdateUsername,
+6 -2
View File
@@ -1,4 +1,8 @@
const { ErrNotFound, ErrNotAuthorized } = require('../../errors');
const {
ErrNotFound,
ErrNotAuthorized,
ErrPasswordIncorrect,
} = require('../../errors');
const Users = require('../../services/users');
const migrationHelpers = require('../../services/migration/helpers');
const {
@@ -170,7 +174,7 @@ const changeUserPassword = async (ctx, oldPassword, newPassword) => {
// Verify the old password.
const validPassword = await user.verifyPassword(oldPassword);
if (!validPassword) {
throw new ErrNotAuthorized();
throw new ErrPasswordIncorrect();
}
// Change the users password now.
+1
View File
@@ -225,6 +225,7 @@ en:
embedlink:
copy: "Copy to Clipboard"
error:
PASSWORD_INCORRECT: "Your current password was entered incorrectly"
COMMENT_PARENT_NOT_VISIBLE: "The comment that you're replying to has been removed or doesn't exist."
EMAIL_VERIFICATION_TOKEN_INVALID: "Email verification token is invalid."
EMAIL_ALREADY_VERIFIED: "Email address already verified."
@@ -127,12 +127,11 @@ class ChangePassword extends React.Component {
'success',
t('talk-plugin-local-auth.change_password.changed_password_msg')
);
this.clearForm();
this.disableEditing();
} catch (err) {
this.props.notify('error', getErrorMessages(err));
}
this.clearForm();
this.disableEditing();
};
onForgotPassword = async () => {