Music collection management tool
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: redirect back to login on logout

+8
+8
web/src/lib/auth.tsx
··· 1 + import { useRouter } from '@tanstack/react-router' 1 2 import { createContext, useContext, useState, useEffect, type ReactNode } from 'react' 2 3 import { toast } from 'sonner' 3 4 ··· 42 43 } 43 44 44 45 export function AuthProvider({ children }: { children: ReactNode }) { 46 + const router = useRouter(); 45 47 const [user, setUser] = useState<User | null>(null) 46 48 const [loading, setLoading] = useState(true) 47 49 ··· 56 58 setLoading(false) 57 59 }) 58 60 }, []) 61 + 62 + useEffect(() => { 63 + if (!loading && user == null) { 64 + router.navigate({ to: '/login' }); 65 + } 66 + }, [loading, user]); 59 67 60 68 const signin = async (username: string, password: string) => { 61 69 const res = await fetch(`/api/auth/signin`, {