diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx
index 214dcd4..ae7fc0c 100644
--- a/src/pages/Login.tsx
+++ b/src/pages/Login.tsx
@@ -31,8 +31,14 @@ export function Login() {
throw new Error(authError.message ?? 'Sign in failed')
}
- setAuthenticated(true)
- navigate('/')
+ // After successful signIn, force a session fetch to confirm the cookie is set
+ // before navigating to the protected route
+ const sessionResult = await authClient.getSession()
+ if (sessionResult.data) {
+ navigate('/')
+ } else {
+ setError('Sign in failed. Please try again.')
+ }
} catch {
if (import.meta.env.VITE_MOCK_AUTH === 'true') {
setAuthenticated(true)
@@ -46,7 +52,7 @@ export function Login() {
}
return (
-
+
CartSnitch
Track prices. Save money.
@@ -88,10 +94,10 @@ export function Login() {
Don't have an account?{' '}
-
+
Sign up
-
+
)
}
diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx
index a65e7b6..c75e2d6 100644
--- a/src/pages/Register.tsx
+++ b/src/pages/Register.tsx
@@ -38,8 +38,15 @@ export function Register() {
throw new Error(authError.message ?? 'Registration failed')
}
- setAuthenticated(true)
- navigate('/')
+ // After successful signUp, force a session fetch to confirm the cookie is set
+ // before navigating to the protected route
+ const sessionResult = await authClient.getSession()
+ if (sessionResult.data) {
+ navigate('/')
+ } else {
+ // Session not established — show success message and link to login
+ setError('Account created! Please sign in.')
+ }
} catch {
if (import.meta.env.VITE_MOCK_AUTH === 'true') {
setAuthenticated(true)