Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions web/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ export function useAuth() {
const signIn = useCallback((token: string | null, user: AuthUser) => {
storeAuth(token, user)
setState({ user, token: token ?? COOKIE_SENTINEL, loading: false })
// Navigate off the login route. The legacy password flow (unlike the
// magic-link flow, which redirects through /auth/callback → /) never
// changes the hash, so without this the route stays 'login' and App's
// `route === 'login'` gate re-renders <Login> forever despite valid auth
// — the "clicking Sign in does nothing" trap. Only redirect when actually
// sitting on the login route so we never clobber a deliberate deep link.
try {
const h = window.location.hash
if (h === '' || h === '#' || h.startsWith('#/login')) window.location.hash = '#/'
} catch {}
}, [])

const signOut = useCallback(() => {
Expand Down
Loading