mirror of
https://github.com/wassname/talk.git
synced 2026-07-19 11:28:50 +08:00
cleaned up refs to passwor dhash
This commit is contained in:
@@ -5,7 +5,6 @@ const {
|
||||
ErrIncorrectPassword,
|
||||
} = require('./errors');
|
||||
const { get } = require('lodash');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
// hasLocalProfile checks a user's profiles to see if they already have a local
|
||||
// profile associated with their account.
|
||||
@@ -88,7 +87,7 @@ async function attachUserLocalAuth(ctx, email, password) {
|
||||
await Users.isValidPassword(password);
|
||||
|
||||
// Hash the new password.
|
||||
const hashedPassword = await bcrypt.hash(password, 10);
|
||||
const hashedPassword = await Users.hashPassword(password);
|
||||
|
||||
try {
|
||||
// Associate the account with the user.
|
||||
|
||||
+7
-3
@@ -557,7 +557,7 @@ class Users {
|
||||
throw new ErrPasswordTooShort();
|
||||
}
|
||||
|
||||
const hashedPassword = await bcrypt.hash(password, SALT_ROUNDS);
|
||||
const hashedPassword = await Users.hashPassword(password);
|
||||
|
||||
return User.update(
|
||||
{ id },
|
||||
@@ -634,7 +634,7 @@ class Users {
|
||||
Users.isValidPassword(password),
|
||||
]);
|
||||
|
||||
const hashedPassword = await bcrypt.hash(password, SALT_ROUNDS);
|
||||
const hashedPassword = await Users.hashPassword(password);
|
||||
|
||||
let user = new User({
|
||||
username,
|
||||
@@ -811,6 +811,10 @@ class Users {
|
||||
return { user, redirect, version };
|
||||
}
|
||||
|
||||
static async hashPassword(password) {
|
||||
return bcrypt.hash(password, SALT_ROUNDS);
|
||||
}
|
||||
|
||||
// TODO: update doc
|
||||
static async resetPassword(token, password) {
|
||||
const { user, redirect, version } = await this.verifyPasswordResetToken(
|
||||
@@ -821,7 +825,7 @@ class Users {
|
||||
throw new ErrPasswordTooShort();
|
||||
}
|
||||
|
||||
const hashedPassword = await bcrypt.hash(password, SALT_ROUNDS);
|
||||
const hashedPassword = await Users.hashPassword(password);
|
||||
|
||||
// Update the user's password.
|
||||
await User.update(
|
||||
|
||||
Reference in New Issue
Block a user