mirror of
https://github.com/wassname/talk.git
synced 2026-07-18 12:40:13 +08:00
Added incorrect password error
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user