Fix: Clear auth state when no user data is returned
Co-authored-by: tumurbarsnarantuya <tumurbarsnarantuya@gmail.com>
This commit is contained in:
parent
fcc5872fda
commit
b6e50df81d
@ -343,7 +343,15 @@ export const useAuthStore = create<AuthStoreState>()(
|
||||
if (user) {
|
||||
set({ user, isAuthenticated: true, loading: false, error: null, hasCheckedAuth: true });
|
||||
} 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) {
|
||||
// Token is invalid, clear auth state
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user