diff options
| author | l3wdfut4pwr <l3wdfut4pwr@gmail.com> | 2026-04-09 15:20:56 +0300 |
|---|---|---|
| committer | l3wdfut4pwr <l3wdfut4pwr@gmail.com> | 2026-04-09 15:20:56 +0300 |
| commit | d3bceed42caca6ac8c39ebe0c929f7d3c13d2bfa (patch) | |
| tree | 3f641db6d83d2de03f972e11761b95adc7359317 /src/lib | |
| parent | 3b68dee3f51b54cb452641336f3750574441f9bb (diff) | |
update settings
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/contexts/Auth.context.tsx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/contexts/Auth.context.tsx b/src/lib/contexts/Auth.context.tsx index 4e567ba..127c942 100644 --- a/src/lib/contexts/Auth.context.tsx +++ b/src/lib/contexts/Auth.context.tsx @@ -5,7 +5,8 @@ export type User = { id: number; username: string; email: string; - password?: string; + password: boolean; + google_id?: string | null; avatar?: string; banner_file?: string; description?: string; @@ -49,18 +50,19 @@ export const AuthContextProvider = ({ children }: React.PropsWithChildren) => { useEffect(() => { const fetchUser = async () => { - const hasCookies = document.cookie.includes('access_token'); - if (!hasCookies) return; - try { const res = await fetch(`${API_URL}/api/me`, { credentials: 'include', }); - if (!res.ok) return; - const userData = await res.json(); - setUser(userData); + if (!res.ok) { + setUser(null); + return; + } + const data = await res.json(); + setUser(data.authenticated ? data.user : null); } catch (err) { console.error('Error fetching user:', err); + setUser(null); } }; |
