Commit a9e8cf6
fix(auth): stop password-login session being wiped on initial mount
Two bugs in onAuthStateChange that bounced password-authed users to
/login when they navigated directly to a deep URL:
- The handler unconditionally cleared dbUser when Supabase had no
session, even if a custom JWT (password login) was active.
- The handler unconditionally flipped loading=false on every Supabase
event, including the initial INITIAL_SESSION emitted before the
custom-JWT fetchDbUser had finished. Route guards then ran with
loading=false and dbUser=null and redirected.
Now: only clear dbUser if there is no custom token, and let the
custom-token path own setLoading(false) when it's the active session.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 229c6de commit a9e8cf6
1 file changed
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
85 | 89 | | |
| 90 | + | |
86 | 91 | | |
87 | | - | |
88 | | - | |
| 92 | + | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| |||
0 commit comments