0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

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

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