fix(editor): Only prompt for MFA code when email is updated (#15065)

This commit is contained in:
Ricardo Espinoza
2025-05-05 07:59:18 -04:00
committed by GitHub
parent 1d4f63985b
commit aa4607e7b5
2 changed files with 48 additions and 14 deletions

View File

@@ -151,24 +151,25 @@ async function saveUserSettings(params: UserBasicDetailsWithMfa) {
}
async function onSubmit(form: UserBasicDetailsForm) {
if (!usersStore.currentUser?.mfaEnabled) {
await saveUserSettings(form);
return;
}
const emailChanged = usersStore.currentUser?.email !== form.email;
uiStore.openModal(PROMPT_MFA_CODE_MODAL_KEY);
if (usersStore.currentUser?.mfaEnabled && emailChanged) {
uiStore.openModal(PROMPT_MFA_CODE_MODAL_KEY);
promptMfaCodeBus.once('closed', async (payload: MfaModalEvents['closed']) => {
if (!payload) {
// User closed the modal without submitting the form
return;
}
promptMfaCodeBus.once('closed', async (payload: MfaModalEvents['closed']) => {
if (!payload) {
// User closed the modal without submitting the form
return;
}
await saveUserSettings({
...form,
mfaCode: payload.mfaCode,
await saveUserSettings({
...form,
mfaCode: payload.mfaCode,
});
});
});
} else {
await saveUserSettings(form);
}
}
async function updateUserBasicInfo(userBasicInfo: UserBasicDetailsWithMfa) {