diff --git a/ui/core/app/components/form/account/password/index.js b/ui/core/app/components/form/account/password/index.js index caf239d17..02f208746 100644 --- a/ui/core/app/components/form/account/password/index.js +++ b/ui/core/app/components/form/account/password/index.js @@ -1,4 +1,5 @@ import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; export default class FormAccountPasswordIndexComponent extends Component { @@ -9,7 +10,16 @@ export default class FormAccountPasswordIndexComponent extends Component { * Account password property * @type {string} */ - password; + @tracked password; + + // =methods + + /** + * Unsets the password field. + */ + resetPassword() { + this.password = null; + } // =actions @@ -20,7 +30,13 @@ export default class FormAccountPasswordIndexComponent extends Component { */ @action submit(fn) { - this.args.model.isNew ? fn(this.password) : fn(); - delete this.password; + try { + this.args.model.isNew ? fn(this.password) : fn(); + } catch (e) { + // We want to guarantee password is unset + this.resetPassword(); + // But we don't want to silence the error + throw e; + } } } diff --git a/ui/core/app/components/form/account/password/set-password/index.js b/ui/core/app/components/form/account/password/set-password/index.js index a4039b76d..2449d4c6f 100644 --- a/ui/core/app/components/form/account/password/set-password/index.js +++ b/ui/core/app/components/form/account/password/set-password/index.js @@ -39,8 +39,14 @@ export default class FormAccountPasswordSetPasswordIndexComponent extends Compon */ @action submit(fn) { - fn(this.password); - this.resetPassword(); + try { + fn(this.password); + } catch (e) { + // We want to guarantee password is unset + this.resetPassword(); + // But we don't want to silence the error + throw e; + } } /** @@ -49,8 +55,14 @@ export default class FormAccountPasswordSetPasswordIndexComponent extends Compon */ @action cancel(fn) { - fn(); - this.resetPassword(); + try { + fn(); + } catch (e) { + // We want to guarantee password is unset + this.resetPassword(); + // But we don't want to silence the error + throw e; + } } }