FIX: Update remaining backup code count after creation (#22475)

This commit is contained in:
Isaac Janzen 2023-07-10 13:37:14 -05:00 committed by GitHub
parent 0b16fc8172
commit 049c4b606a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -47,6 +47,7 @@ export default class SecondFactorBackupEdit extends Component {
this.args.model.setBackupEnabled(true); this.args.model.setBackupEnabled(true);
this.backupEnabled = true; this.backupEnabled = true;
this.remainingCodes = response.backup_codes.length; this.remainingCodes = response.backup_codes.length;
this.args.model.setCodesRemaining(this.remainingCodes);
}) })
.catch((error) => { .catch((error) => {
this.args.closeModal(); this.args.closeModal();

View File

@ -68,6 +68,11 @@ export default Controller.extend(CanCheckEmails, {
this.set("backupEnabled", value); this.set("backupEnabled", value);
}, },
@action
setCodesRemaining(value) {
this.model.set("second_factor_remaining_backup_codes", value);
},
@action @action
loadSecondFactors() { loadSecondFactors() {
if (this.dirty === false) { if (this.dirty === false) {
@ -322,6 +327,7 @@ export default Controller.extend(CanCheckEmails, {
markDirty: () => this.markDirty(), markDirty: () => this.markDirty(),
onError: (e) => this.handleError(e), onError: (e) => this.handleError(e),
setBackupEnabled: (e) => this.setBackupEnabled(e), setBackupEnabled: (e) => this.setBackupEnabled(e),
setCodesRemaining: (e) => this.setCodesRemaining(e),
}, },
}); });
}, },