diff --git a/apps/web/src/app/(auth)/sign-in/page.tsx b/apps/web/src/app/(auth)/sign-in/page.tsx index 94dff0e..c8337fe 100644 --- a/apps/web/src/app/(auth)/sign-in/page.tsx +++ b/apps/web/src/app/(auth)/sign-in/page.tsx @@ -18,19 +18,26 @@ export default function SignInPage() { setLoading(true); try { - const result = await signIn.email({ - email, - password, - }); - - if (result.error) { - console.error('Sign in error:', result.error); - setError(result.error.message || result.error.code || 'Failed to sign in'); - return; - } - - router.push('/dashboard'); - } catch { + await signIn.email( + { + email, + password, + callbackURL: '/dashboard', + }, + { + onSuccess: () => { + router.refresh(); + router.push('/dashboard'); + }, + onError: (ctx) => { + console.error('Sign in error:', ctx.error); + setError(ctx.error.message || 'Failed to sign in'); + }, + } + ); + return; // onSuccess/onError handle the flow + } catch (err) { + console.error('Sign in exception:', err); setError('An unexpected error occurred'); } finally { setLoading(false); diff --git a/apps/web/src/app/(auth)/sign-up/page.tsx b/apps/web/src/app/(auth)/sign-up/page.tsx index 8d23fe2..b55a7d1 100644 --- a/apps/web/src/app/(auth)/sign-up/page.tsx +++ b/apps/web/src/app/(auth)/sign-up/page.tsx @@ -19,19 +19,24 @@ export default function SignUpPage() { setLoading(true); try { - const result = await signUp.email({ - name, - email, - password, - }); - - if (result.error) { - console.error('Sign up error:', result.error); - setError(result.error.message || result.error.code || 'Failed to create account'); - return; - } - - router.push('/verify-email'); + await signUp.email( + { + name, + email, + password, + callbackURL: '/verify-email', + }, + { + onSuccess: () => { + router.push('/verify-email'); + }, + onError: (ctx) => { + console.error('Sign up error:', ctx.error); + setError(ctx.error.message || 'Failed to create account'); + }, + } + ); + return; // onSuccess/onError handle the flow } catch { setError('An unexpected error occurred'); } finally {