diff --git a/dashboard/src/components/dialogs/DisableTwoFADialog.vue b/dashboard/src/components/dialogs/DisableTwoFADialog.vue
new file mode 100644
index 000000000..fd3885b30
--- /dev/null
+++ b/dashboard/src/components/dialogs/DisableTwoFADialog.vue
@@ -0,0 +1,85 @@
+
+
+
+
+
diff --git a/dashboard/src/models/ProfileModel.js b/dashboard/src/models/ProfileModel.js
index 2af26baa0..08ce9ddd3 100644
--- a/dashboard/src/models/ProfileModel.js
+++ b/dashboard/src/models/ProfileModel.js
@@ -194,14 +194,14 @@ function create() {
return [null];
},
async disableTwoFA(password) {
- let error, result;
+ let result;
try {
result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/twofactorauthentication_disable`, { password }, { access_token: accessToken });
} catch (e) {
- error = e;
+ return [e];
}
- if (error || result.status !== 204) return [error || result];
+ if (result.status !== 204) return [result];
return [null];
},
async setNotificationConfig(notificationConfig) {
diff --git a/dashboard/src/views/ProfileView.vue b/dashboard/src/views/ProfileView.vue
index 73470e5e2..4142c1350 100644
--- a/dashboard/src/views/ProfileView.vue
+++ b/dashboard/src/views/ProfileView.vue
@@ -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 () => {
+