summaryrefslogtreecommitdiff
path: root/src/lib/contexts
diff options
context:
space:
mode:
authorl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-09 15:20:56 +0300
committerl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-09 15:20:56 +0300
commitd3bceed42caca6ac8c39ebe0c929f7d3c13d2bfa (patch)
tree3f641db6d83d2de03f972e11761b95adc7359317 /src/lib/contexts
parent3b68dee3f51b54cb452641336f3750574441f9bb (diff)
update settings
Diffstat (limited to 'src/lib/contexts')
-rw-r--r--src/lib/contexts/Auth.context.tsx16
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);
}
};