Rework the 2fa disable dialog

This commit is contained in:
Johannes Zellner
2025-06-11 10:47:47 +02:00
parent 53b83909ed
commit 1ddba4a76f
3 changed files with 92 additions and 19 deletions
+4 -16
View File
@@ -13,6 +13,7 @@ import SettingsItem from '../components/SettingsItem.vue';
import PrimaryEmailDialog from '../components/dialogs/PrimaryEmailDialog.vue';
import FallbackEmailDialog from '../components/dialogs/FallbackEmailDialog.vue';
import PasswordChangeDialog from '../components/dialogs/PasswordChangeDialog.vue';
import DisableTwoFADialog from '../components/dialogs/DisableTwoFADialog.vue';
import Section from '../components/Section.vue';
import ApiTokens from '../components/ApiTokens.vue';
import ImagePicker from '../components/ImagePicker.vue';
@@ -33,6 +34,7 @@ const inputDialog = useTemplateRef('inputDialog');
const primaryEmailDialog = useTemplateRef('primaryEmailDialog');
const fallbackEmailDialog = useTemplateRef('fallbackEmailDialog');
const passwordChangeDialog = useTemplateRef('passwordChangeDialog');
const disableTwoFADialog = useTemplateRef('disableTwoFADialog');
// Language selector
const languages = ref([]);
@@ -144,22 +146,7 @@ async function onTwoFAEnable() {
}
async function onTwoFADisable() {
const password = await inputDialog.value.prompt({
message: t('profile.disable2FA.title'),
modal: true,
placeholder: t('appstore.accountDialog.password'),
type: 'password',
confirmLabel: t('main.dialog.yes'),
rejectLabel: t('main.dialog.no'),
rejectStyle: 'secondary',
});
if (!password) return;
const [error] = await profileModel.disableTwoFA(password);
if (error) return onTwoFADisable();
await refreshProfile();
disableTwoFADialog.value.open();
}
@@ -203,6 +190,7 @@ onMounted(async () => {
<PrimaryEmailDialog ref="primaryEmailDialog" @success="refreshProfile"/>
<FallbackEmailDialog ref="fallbackEmailDialog" @success="refreshProfile"/>
<PasswordChangeDialog ref="passwordChangeDialog" @success="refreshProfile"/>
<DisableTwoFADialog ref="disableTwoFADialog" @success="refreshProfile"/>
<Dialog ref="twoFADialog" :title="$t('profile.enable2FA.title')" :show-x="!twoFAModal" :modal="twoFAModal">
<div style="text-align: center; max-width: 420px">