diff --git a/dashboard/src/components/dialogs/FallbackEmailDialog.vue b/dashboard/src/components/dialogs/FallbackEmailDialog.vue new file mode 100644 index 000000000..4ebdf8d4a --- /dev/null +++ b/dashboard/src/components/dialogs/FallbackEmailDialog.vue @@ -0,0 +1,93 @@ + + + diff --git a/dashboard/src/components/dialogs/PrimaryEmailDialog.vue b/dashboard/src/components/dialogs/PrimaryEmailDialog.vue index 74991ab78..19ea6275a 100644 --- a/dashboard/src/components/dialogs/PrimaryEmailDialog.vue +++ b/dashboard/src/components/dialogs/PrimaryEmailDialog.vue @@ -49,6 +49,7 @@ async function onSubmit() { defineExpose({ async open(e) { email.value = e; + password.value = ''; busy.value = false; formError.value = {}; dialog.value.open(); diff --git a/dashboard/src/models/ProfileModel.js b/dashboard/src/models/ProfileModel.js index 93f3a1a12..9f9eb6a7d 100644 --- a/dashboard/src/models/ProfileModel.js +++ b/dashboard/src/models/ProfileModel.js @@ -103,17 +103,15 @@ function create() { return [null]; }, async setFallbackEmail(fallbackEmail, password) { - let error, result; + let result; try { result = await fetcher.post(`${API_ORIGIN}/api/v1/profile/fallback_email`, { fallbackEmail, password }, { access_token: accessToken }); } catch (e) { - error = e; + return [e]; } - if (error) return error; - if (result.status !== 204) return result; - - return null; + if (result.status !== 204) return [result]; + return [null]; }, async setLanguage(language) { let error, result; diff --git a/dashboard/src/views/ProfileView.vue b/dashboard/src/views/ProfileView.vue index 38c6c2521..9e810db1d 100644 --- a/dashboard/src/views/ProfileView.vue +++ b/dashboard/src/views/ProfileView.vue @@ -11,6 +11,7 @@ import NotificationSettings from '../components/NotificationSettings.vue'; import AppPasswords from '../components/AppPasswords.vue'; import SettingsItem from '../components/SettingsItem.vue'; import PrimaryEmailDialog from '../components/dialogs/PrimaryEmailDialog.vue'; +import FallbackEmailDialog from '../components/dialogs/FallbackEmailDialog.vue'; import Section from '../components/Section.vue'; import ApiTokens from '../components/ApiTokens.vue'; import ImagePicker from '../components/ImagePicker.vue'; @@ -29,6 +30,7 @@ const config = ref({}); const user = ref({}); const inputDialog = useTemplateRef('inputDialog'); const primaryEmailDialog = useTemplateRef('primaryEmailDialog'); +const fallbackEmailDialog = useTemplateRef('fallbackEmailDialog'); // Language selector const languages = ref([]); @@ -73,23 +75,7 @@ function onChangeEmail(currentEmail) { } async function onChangeFallbackEmail(currentFallbackEmail) { - const result = await inputDialog.value.prompt({ - message: [ t('profile.changeFallbackEmail.title'), t('profile.changeEmail.password') ], - type: [ 'email', 'password' ], - modal: false, - value: [ currentFallbackEmail, '' ], - confirmLabel: t('main.dialog.save'), - confirmStyle: 'primary', - rejectLabel: t('main.dialog.cancel'), - rejectStyle: 'secondary', - }); - - if (!result || !result[1] || currentFallbackEmail === result[0]) return; - - const error = await profileModel.setFallbackEmail(result[0], result[1]); - if (error) return console.error('Failed to set fallback email', error); - - await refreshProfile(); + fallbackEmailDialog.value.open(currentFallbackEmail); } async function onAvatarSubmit(file) { @@ -227,6 +213,7 @@ onMounted(async () => {
+
diff --git a/src/users.js b/src/users.js index 6c9936823..4bacf2cf9 100644 --- a/src/users.js +++ b/src/users.js @@ -396,7 +396,7 @@ async function verify(userId, password, identifier, options) { if (error) throw new BoxError(BoxError.CRYPTO_ERROR, error); const derivedKeyHex = Buffer.from(derivedKey, 'binary').toString('hex'); - if (derivedKeyHex !== user.password) throw new BoxError(BoxError.INVALID_CREDENTIALS, 'Username and password does not match'); + if (derivedKeyHex !== user.password) throw new BoxError(BoxError.INVALID_CREDENTIALS, 'Wrong password'); localTotpCheck = user.twoFactorAuthenticationEnabled; }