From d507eab3e877f8159fd43b8d048ef80d9fc6c13b Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Tue, 7 Nov 2017 15:09:57 +0700 Subject: [PATCH] Changed logic for importPersistUser option (#9203) no issue - `importing` and `importPersistUser` are two different concepts --- core/server/models/user.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/server/models/user.js b/core/server/models/user.js index 16f30a8f69..c8232b430b 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -151,14 +151,14 @@ User = ghostBookshelf.Model.extend({ if (self.isNew() || self.hasChanged('password')) { this.set('password', String(this.get('password'))); - if (options.importing) { - // CASE: import with `importPersistUser` should always be an bcrypt password already, - // and won't re-hash or overwrite it. - // In case the password is not bcrypt hashed we fall back to the standard behaviour. - if (options.importPersistUser && this.get('password').match(/^\$2[ayb]\$.{56}$/i)) { - return; - } + // CASE: import with `importPersistUser` should always be an bcrypt password already, + // and won't re-hash or overwrite it. + // In case the password is not bcrypt hashed we fall back to the standard behaviour. + if (options.importPersistUser && this.get('password').match(/^\$2[ayb]\$.{56}$/i)) { + return; + } + if (options.importing) { // always set password to a random uid when importing this.set('password', utils.uid(50));