update
This commit is contained in:
@@ -139,9 +139,12 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
||||
const user = await authService.getCurrentUser();
|
||||
setUser(user);
|
||||
setState((prev) => ({ ...prev, user }));
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error('Failed to refresh user data:', error);
|
||||
logout();
|
||||
// Only logout on explicit 401 — network errors / 5xx should not destroy the session
|
||||
if (error?.response?.status === 401) {
|
||||
logout();
|
||||
}
|
||||
}
|
||||
}, [logout]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user