From 8fee07a3f85c3b7c5d0c0f54d6a5b47845e58994 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 3 May 2018 09:58:49 -0600 Subject: [PATCH] cleaned up refs to passwor dhash --- plugins/talk-plugin-local-auth/server/mutators.js | 3 +-- services/users.js | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/talk-plugin-local-auth/server/mutators.js b/plugins/talk-plugin-local-auth/server/mutators.js index cb34bed7a..95ab7cefc 100644 --- a/plugins/talk-plugin-local-auth/server/mutators.js +++ b/plugins/talk-plugin-local-auth/server/mutators.js @@ -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. diff --git a/services/users.js b/services/users.js index e53df4119..54fe057ba 100644 --- a/services/users.js +++ b/services/users.js @@ -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(