mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐛 Fixed "Are you sure" modal being shown incorrectly after toggling private mode (#964)
closes TryGhost/Ghost#9472 - add `changedAttributes()` passthrough to `settings` service - use `changedAttributes()` in general settings `toggleIsPrivate` method to reset the password to the last known value when disabling private mode
This commit is contained in:
parent
88af30f855
commit
654beb7e2f
2 changed files with 16 additions and 4 deletions
|
@ -103,12 +103,20 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleIsPrivate(isPrivate) {
|
toggleIsPrivate(isPrivate) {
|
||||||
this.set('settings.isPrivate', isPrivate);
|
let settings = this.get('settings');
|
||||||
this.get('settings.errors').remove('password');
|
|
||||||
|
settings.set('isPrivate', isPrivate);
|
||||||
|
settings.get('errors').remove('password');
|
||||||
|
|
||||||
|
let changedAttrs = settings.changedAttributes();
|
||||||
|
|
||||||
// set a new random password when isPrivate is enabled
|
// set a new random password when isPrivate is enabled
|
||||||
if (isPrivate && this.get('settings.hasDirtyAttributes')) {
|
if (isPrivate && changedAttrs.isPrivate) {
|
||||||
this.get('settings').set('password', randomPassword());
|
settings.set('password', randomPassword());
|
||||||
|
|
||||||
|
// reset the password when isPrivate is disabled
|
||||||
|
} else if (changedAttrs.password) {
|
||||||
|
settings.set('password', changedAttrs.password[0]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -68,5 +68,9 @@ export default Service.extend(_ProxyMixin, ValidationEngine, {
|
||||||
|
|
||||||
rollbackAttributes() {
|
rollbackAttributes() {
|
||||||
return this.get('content').rollbackAttributes();
|
return this.get('content').rollbackAttributes();
|
||||||
|
},
|
||||||
|
|
||||||
|
changedAttributes() {
|
||||||
|
return this.get('content').changedAttributes();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue