fix: Don't clear auth when token exists but user is missing (race condition)
This commit is contained in:
@@ -114,7 +114,13 @@ export class AuthService implements OnDestroy {
|
|||||||
}
|
}
|
||||||
} else if (token || user) {
|
} else if (token || user) {
|
||||||
// Inconsistent state - clear everything
|
// Inconsistent state - clear everything
|
||||||
console.warn('Inconsistent auth state detected, clearing...');
|
console.warn('Inconsistent auth state detected, clearing... token:', !!token, 'user:', !!user);
|
||||||
|
// Don't clear if we have a valid token - just log and continue
|
||||||
|
// This prevents race conditions from clearing valid auth state
|
||||||
|
if (token) {
|
||||||
|
console.warn('Token exists but user missing - NOT clearing (likely race condition)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.clearAuthState();
|
this.clearAuthState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +287,8 @@ export class AuthService implements OnDestroy {
|
|||||||
// Delay clearing the login flag to allow async storage events to be ignored
|
// Delay clearing the login flag to allow async storage events to be ignored
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isLoginInProgress = false;
|
this.isLoginInProgress = false;
|
||||||
}, 500);
|
console.log('[AUTH DEBUG] Login guard cleared after delay');
|
||||||
|
}, 2000);
|
||||||
this._isLoading.set(false);
|
this._isLoading.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user