Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge 8b7171a into a947c03
Browse files Browse the repository at this point in the history
  • Loading branch information
hey24sheep committed Mar 9, 2018
2 parents a947c03 + 8b7171a commit 1454b05
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/controllers/settings/general.js
Expand Up @@ -103,12 +103,20 @@ export default Controller.extend({
},

toggleIsPrivate(isPrivate) {
this.set('settings.isPrivate', isPrivate);
this.get('settings.errors').remove('password');
let settings = this.get('settings');

settings.set('isPrivate', isPrivate);
settings.get('errors').remove('password');

let changedAttrs = settings.changedAttributes();

// set a new random password when isPrivate is enabled
if (isPrivate && this.get('settings.hasDirtyAttributes')) {
this.get('settings').set('password', randomPassword());
if (isPrivate && changedAttrs.isPrivate) {
settings.set('password', randomPassword());

// reset the password when isPrivate is disabled
} else if (changedAttrs.password) {
settings.set('password', changedAttrs.password[0]);
}
},

Expand Down
4 changes: 4 additions & 0 deletions app/services/settings.js
Expand Up @@ -68,5 +68,9 @@ export default Service.extend(_ProxyMixin, ValidationEngine, {

rollbackAttributes() {
return this.get('content').rollbackAttributes();
},

changedAttributes() {
return this.get('content').changedAttributes();
}
});

0 comments on commit 1454b05

Please sign in to comment.