fix(auth): kimlik doğrulama hatasında durumu temizle

Kullanıcı verisi getirme başarısız olduğunda artık tüm kimlik doğrulama
durumunu (token, kullanıcı bilgileri) temizler, böylece eski oturum
bilgileri kalıcı olmaz.
This commit is contained in:
2026-01-26 15:34:12 +00:00
parent 2ff3fb6ee6
commit 535b5cbdc2
2 changed files with 6 additions and 1 deletions

View File

@@ -23,7 +23,11 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
setToken(stored);
fetchMe()
.then((data) => setUser({ username: data.username }))
.catch(() => setAuthToken(undefined))
.catch(() => {
setAuthToken(undefined);
setToken(null);
setUser(null);
})
.finally(() => setLoading(false));
} else {
setLoading(false);