From 6eb91e4aedc2ec70c77a936ca6105750c342e4c3 Mon Sep 17 00:00:00 2001 From: Jennifer Weber Date: Thu, 28 Aug 2025 20:51:07 -0700 Subject: [PATCH] Show signin and signup errors on form --- .../dialog/content/SignInContent.vue | 46 ++++++++++++++++--- .../dialog/content/signin/SignInForm.vue | 10 ++++ .../dialog/content/signin/SignUpForm.vue | 10 ++++ .../auth/useFirebaseAuthActions.ts | 41 ++++++++++------- 4 files changed, 84 insertions(+), 23 deletions(-) diff --git a/src/components/dialog/content/SignInContent.vue b/src/components/dialog/content/SignInContent.vue index 05303ce69..b0067891a 100644 --- a/src/components/dialog/content/SignInContent.vue +++ b/src/components/dialog/content/SignInContent.vue @@ -32,12 +32,16 @@ - + @@ -164,32 +168,62 @@ const authActions = useFirebaseAuthActions() const isSecureContext = window.isSecureContext const isSignIn = ref(true) const showApiKeyForm = ref(false) +const authError = ref('') const toggleState = () => { isSignIn.value = !isSignIn.value showApiKeyForm.value = false + authError.value = '' +} + +// Custom error handler for inline display +const inlineErrorHandler = (error: unknown) => { + // Set inline error + if (error instanceof Error) { + authError.value = error.message || t('g.unknownError') + } else { + authError.value = t('g.unknownError') + } + // Also show toast (original behavior) + authActions.reportError(error) } const signInWithGoogle = async () => { - if (await authActions.signInWithGoogle()) { + authError.value = '' + if (await authActions.signInWithGoogle(inlineErrorHandler)()) { onSuccess() } } const signInWithGithub = async () => { - if (await authActions.signInWithGithub()) { + authError.value = '' + if (await authActions.signInWithGithub(inlineErrorHandler)()) { onSuccess() } } const signInWithEmail = async (values: SignInData) => { - if (await authActions.signInWithEmail(values.email, values.password)) { + authError.value = '' + if ( + await authActions.signInWithEmail( + values.email, + values.password, + inlineErrorHandler + )() + ) { onSuccess() } } const signUpWithEmail = async (values: SignUpData) => { - if (await authActions.signUpWithEmail(values.email, values.password)) { + authError.value = '' + if ( + await authActions.signUpWithEmail( + values.email, + values.password, + inlineErrorHandler + )() + ) { onSuccess() } } diff --git a/src/components/dialog/content/signin/SignInForm.vue b/src/components/dialog/content/signin/SignInForm.vue index 72ac23bc7..642b35884 100644 --- a/src/components/dialog/content/signin/SignInForm.vue +++ b/src/components/dialog/content/signin/SignInForm.vue @@ -59,6 +59,11 @@ }} + + + {{ authError }} + +