FIX: Reload page after adding 2FA when it is enforced (#24803)

When 2FA is enforced and the user has no key or TOTP on their account, we
block navigating away from the page until they have added one. However,
we don't reload the page after they have added one, so the user is left
with a page that still says they need to add 2FA.
This commit is contained in:
Penar Musaraj 2023-12-11 10:56:30 -05:00 committed by GitHub
parent b5fb8e89eb
commit af23fec835
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -130,6 +130,9 @@ export default class SecondFactorAddSecurityKey extends Component {
this.args.model.markDirty();
this.errorMessage = null;
this.args.closeModal();
if (this.args.model.enforcedSecondFactor) {
window.location.reload();
}
})
.catch((error) => this.args.model.onError(error))
.finally(() => (this.loading = false));

View File

@ -61,6 +61,9 @@ export default class SecondFactorAddTotp extends Component {
this.args.model.markDirty();
this.errorMessage = null;
this.args.closeModal();
if (this.args.model.enforcedSecondFactor) {
window.location.reload();
}
})
.catch((error) => this.args.model.onError(error))
.finally(() => (this.loading = false));

View File

@ -53,6 +53,7 @@ export default Controller.extend(CanCheckEmails, {
await this.modal.show(SecondFactorAddTotp, {
model: {
secondFactor: this.model,
enforcedSecondFactor: this.currentUser.enforcedSecondFactor,
markDirty: () => this.markDirty(),
onError: (e) => this.handleError(e),
},
@ -68,6 +69,7 @@ export default Controller.extend(CanCheckEmails, {
await this.modal.show(SecondFactorAddSecurityKey, {
model: {
secondFactor: this.model,
enforcedSecondFactor: this.currentUser.enforcedSecondFactor,
markDirty: this.markDirty,
onError: this.handleError,
},