Changed logic for importPersistUser option (#9203)

no issue

- `importing` and `importPersistUser` are two different concepts
This commit is contained in:
Aileen Nowak 2017-11-07 15:09:57 +07:00 committed by Katharina Irrgang
parent dbd22d7447
commit d507eab3e8
1 changed files with 7 additions and 7 deletions

View File

@ -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));