Skip to content

Open source personal finance application

fix(auth): add error callback URL for Google sign-in and handle API errors

Ilya Komichevd61745e074a8
diff --git a/app/app/pages/login.vue b/app/app/pages/login.vue
index 982bfea7..e12d67b7 100644
--- a/app/app/pages/login.vue
+++ b/app/app/pages/login.vue
@@ -35,7 +35,11 @@ async function signInWithGoogle() {
localStorage.removeItem('better-auth_session_data')
try {
- const result = await signIn.social({ callbackURL: `${window.location.origin}/auth/callback`, provider: 'google' })
+ const result = await signIn.social({
+ callbackURL: `${window.location.origin}/auth/callback`,
+ errorCallbackURL: `${window.location.origin}/login`,
+ provider: 'google',
+ })
if (result.data?.url) {
window.location.href = result.data.url
diff --git a/app/convex/auth.ts b/app/convex/auth.ts
index 53189f34..c80f8216 100644
--- a/app/convex/auth.ts
+++ b/app/convex/auth.ts
@@ -21,6 +21,9 @@ function createAuth(ctx: GenericCtx<DataModel>) {
},
baseURL: siteUrl,
database: authComponent.adapter(ctx),
+ onAPIError: {
+ errorURL: `${appUrl}/login`,
+ },
plugins: [
convex({
authConfig,