Skip to content

[6.x] Fix 2FA setup modal not re-opening#14309

Open
duncanmcclean wants to merge 2 commits into6.xfrom
two-factor-setup-modal
Open

[6.x] Fix 2FA setup modal not re-opening#14309
duncanmcclean wants to merge 2 commits into6.xfrom
two-factor-setup-modal

Conversation

@duncanmcclean
Copy link
Member

This pull request fixes an issue where the 2FA setup modal wouldn't re-open after dismissing it by clicking on the modal's overlay.

Noticed this yesterday while testing something.

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

via AI:

Nice fix for the re-open bug — switching to v-model:open is the right call. However, I think the unconditional watcher introduces a regression in the confirm flow.

When confirm() succeeds, it sets setupModalOpen.value = false before setting recoveryCodesModalOpen.value = true. The watcher fires and emits close to the parent:

watch(setupModalOpen, (open) => {
    if (!open) emit('close');
});

The parent handles @close="setupModalOpen = false", which makes its v-if="setupModalOpen" false, unmounting the entire <TwoFactorSetup> component — including the <TwoFactorRecoveryCodesModal> that was about to render. The user would confirm their code but never see their recovery codes.

A minimal fix would be to guard the watcher so it only emits close when we're not transitioning to the recovery codes step:

watch(setupModalOpen, (open) => {
    if (!open && !recoveryCodesModalOpen.value) emit('close');
});

Both ref mutations in confirm() are synchronous, so recoveryCodesModalOpen is already true by the time the watcher callback runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants