From a6b919eb5357dd3523c549681d84ab9723efcd11 Mon Sep 17 00:00:00 2001 From: IanShaw027 Date: Tue, 21 Apr 2026 22:26:11 +0800 Subject: [PATCH] frontend: normalize auth oauth i18n and error toasts --- .../auth/PendingOAuthCreateAccountForm.vue | 53 +++--- .../src/components/auth/TotpLoginModal.vue | 12 +- .../components/auth/WechatOAuthSection.vue | 23 +-- .../PendingOAuthCreateAccountForm.spec.ts | 40 +++++ .../auth/__tests__/TotpLoginModal.spec.ts | 41 +++++ .../auth/__tests__/WechatOAuthSection.spec.ts | 34 +++- frontend/src/i18n/locales/en.ts | 114 ++++++++++++ frontend/src/i18n/locales/zh.ts | 114 ++++++++++++ frontend/src/router/index.ts | 15 +- frontend/src/stores/app.ts | 6 +- frontend/src/views/auth/EmailVerifyView.vue | 37 ++-- .../src/views/auth/ForgotPasswordView.vue | 33 +--- .../src/views/auth/LinuxDoCallbackView.vue | 142 ++++++++------- frontend/src/views/auth/LoginView.vue | 40 ++--- frontend/src/views/auth/OAuthCallbackView.vue | 36 ++-- frontend/src/views/auth/OidcCallbackView.vue | 142 ++++++++------- frontend/src/views/auth/RegisterView.vue | 53 ++---- frontend/src/views/auth/ResetPasswordView.vue | 49 +++--- .../src/views/auth/WechatCallbackView.vue | 165 ++++++++---------- .../views/auth/WechatPaymentCallbackView.vue | 47 ++--- .../__tests__/LinuxDoCallbackView.spec.ts | 35 +++- .../auth/__tests__/OAuthCallbackView.spec.ts | 68 ++++++++ .../auth/__tests__/OidcCallbackView.spec.ts | 31 ++++ .../auth/__tests__/WechatCallbackView.spec.ts | 31 ++++ .../WechatPaymentCallbackView.spec.ts | 20 ++- 25 files changed, 909 insertions(+), 472 deletions(-) create mode 100644 frontend/src/components/auth/__tests__/TotpLoginModal.spec.ts create mode 100644 frontend/src/views/auth/__tests__/OAuthCallbackView.spec.ts diff --git a/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue b/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue index 8e05617f..a566e264 100644 --- a/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue +++ b/frontend/src/components/auth/PendingOAuthCreateAccountForm.vue @@ -5,7 +5,7 @@ :data-testid="`${testIdPrefix}-create-account-email`" type="email" class="input w-full" - placeholder="you@example.com" + :placeholder="t('auth.emailPlaceholder')" :disabled="isSubmitting || isSendingCode" />
@@ -26,16 +26,16 @@ />
- + maxlength="6" + class="input min-w-0 flex-1" + placeholder="123456" + :disabled="isSubmitting" + /> - -

- {{ sendCodeError }} -

-
- -

- {{ errorMessage }} -

-
@@ -102,6 +92,7 @@ import { onMounted, onUnmounted, ref, watch } from 'vue' import { useI18n } from 'vue-i18n' import TurnstileWidget from '@/components/TurnstileWidget.vue' import { getPublicSettings, sendPendingOAuthVerifyCode } from '@/api/auth' +import { useAppStore } from '@/stores' export type PendingOAuthCreateAccountPayload = { email: string @@ -123,6 +114,7 @@ const emit = defineEmits<{ }>() const { t } = useI18n() +const appStore = useAppStore() const email = ref('') const password = ref('') @@ -148,6 +140,21 @@ watch( { immediate: true } ) +watch(sendCodeError, value => { + if (value) { + appStore.showError(value) + } +}) + +watch( + () => props.errorMessage, + value => { + if (value) { + appStore.showError(value) + } + } +) + function clearCountdown() { if (countdownTimer) { clearInterval(countdownTimer) diff --git a/frontend/src/components/auth/TotpLoginModal.vue b/frontend/src/components/auth/TotpLoginModal.vue index 03fa718d..0ae2f482 100644 --- a/frontend/src/components/auth/TotpLoginModal.vue +++ b/frontend/src/components/auth/TotpLoginModal.vue @@ -47,11 +47,6 @@
- -
- {{ error }} -
- @@ -124,13 +118,13 @@

- Choose how to continue + {{ t('auth.oauthFlow.chooseHowToContinue') }}

{{ pendingAccountEmail - ? `Suggested email: ${pendingAccountEmail}` - : `Choose whether to bind an existing ${providerName} account or create a new one.` + ? t('auth.oauthFlow.suggestedEmail', { email: pendingAccountEmail }) + : t('auth.oauthFlow.chooseAccountActionHint') }}

@@ -141,14 +135,14 @@ :disabled="isSubmitting" @click="switchToBindLoginMode()" > - Bind existing account + {{ t('auth.oauthFlow.bindExistingAccount') }}
@@ -157,7 +151,7 @@ - - -
-
-
- -
-
-

- {{ errorMessage }} -

- - {{ t('auth.oidc.backToLogin') }} - -
-
-
-