Fix: Clear auth state when no user data is returned

Co-authored-by: tumurbarsnarantuya <tumurbarsnarantuya@gmail.com>
This commit is contained in:
Cursor Agent 2025-09-18 07:29:49 +00:00
parent fcc5872fda
commit b6e50df81d

View File

@ -343,7 +343,15 @@ export const useAuthStore = create<AuthStoreState>()(
if (user) { if (user) {
set({ user, isAuthenticated: true, loading: false, error: null, hasCheckedAuth: true }); set({ user, isAuthenticated: true, loading: false, error: null, hasCheckedAuth: true });
} else { } else {
set({ loading: false, hasCheckedAuth: true }); // No user data returned, clear auth state
set({
user: null,
tokens: null,
isAuthenticated: false,
loading: false,
error: null,
hasCheckedAuth: true,
});
} }
} catch (error) { } catch (error) {
// Token is invalid, clear auth state // Token is invalid, clear auth state