Skip to content

Commit

Permalink
Changed logic for importPersistUser option (#9203)
Browse files Browse the repository at this point in the history
no issue

- `importing` and `importPersistUser` are two different concepts
  • Loading branch information
aileen authored and kirrg001 committed Nov 7, 2017
1 parent dbd22d7 commit d507eab
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions core/server/models/user.js
Expand Up @@ -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));

Expand Down

0 comments on commit d507eab

Please sign in to comment.