From da3c19f301621e9420d91a1e6a791571cfddd411 Mon Sep 17 00:00:00 2001 From: Matt Venables Date: Mon, 13 Feb 2017 13:18:50 -0500 Subject: [PATCH] Move `password` setting to a constant --- lib/secure-password.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/secure-password.js b/lib/secure-password.js index d833b78..b57f0f4 100644 --- a/lib/secure-password.js +++ b/lib/secure-password.js @@ -1,7 +1,8 @@ module.exports = function (Bookshelf) { 'use strict' const bcrypt = require('bcrypt') - const DEFAULT_PASSWORD_FIELD = 'password_digest' + const DEFAULT_PASSWORD_FIELD = 'password' + const DEFAULT_PASSWORD_DIGEST_FIELD = 'password_digest' const DEFAULT_SALT_ROUNDS = 12 const PasswordMismatchError = require('./error') const proto = Bookshelf.Model.prototype @@ -21,7 +22,7 @@ module.exports = function (Bookshelf) { return model.hasSecurePassword } - return DEFAULT_PASSWORD_FIELD + return DEFAULT_PASSWORD_DIGEST_FIELD } /** @@ -60,7 +61,7 @@ module.exports = function (Bookshelf) { passwordDigestField = passwordField(this) this.virtuals = this.virtuals || {} - this.virtuals.password = { + this.virtuals[DEFAULT_PASSWORD_FIELD] = { get: function getPassword () {}, set: function setPassword (value) { if (value === null) {