Added incorrect password error

This commit is contained in:
Wyatt Johnson
2018-05-02 13:22:15 -06:00
parent 0159918049
commit c1492d1065
3 changed files with 18 additions and 3 deletions
@@ -22,4 +22,14 @@ class ErrLocalProfile extends TalkError {
}
}
module.exports = { ErrLocalProfile, ErrNoLocalProfile };
// ErrIncorrectPassword is returned when the password passed was incorrect.
class ErrIncorrectPassword extends TalkError {
constructor() {
super('Password was incorrect', {
translation_key: 'INCORRECT_PASSWORD',
status: 400,
});
}
}
module.exports = { ErrLocalProfile, ErrNoLocalProfile, ErrIncorrectPassword };
@@ -1,5 +1,9 @@
const { ErrNotAuthorized, ErrNotFound, ErrEmailTaken } = require('errors');
const { ErrNoLocalProfile, ErrLocalProfile } = require('./errors');
const {
ErrNoLocalProfile,
ErrLocalProfile,
ErrIncorrectPassword,
} = require('./errors');
const { get } = require('lodash');
const bcrypt = require('bcryptjs');
@@ -25,7 +29,7 @@ async function updateUserEmailAddress(ctx, email, confirmPassword) {
// Ensure that the password provided matches what we have on file.
if (!await user.verifyPassword(confirmPassword)) {
throw new ErrNotAuthorized();
throw new ErrIncorrectPassword();
}
// Cleanup the email address.
@@ -6,3 +6,4 @@ en:
error:
NO_LOCAL_PROFILE: No existing email address is associated with this account.
LOCAL_PROFILE: An email address is already associated with this account.
INCORRECT_PASSWORD: Provided password was incorrect.