fix(auth): fully clear profile on logout (no stale name/gender after sign-out)
CI/CD / CI - API (dotnet build + engine sim) (push) Successful in 25s
CI/CD / CI - Web (tsc + next build) (push) Successful in 1m11s
CI/CD / Deploy - local stack (db + server + web) (push) Successful in 1m4s

The mock service intentionally KEPT the persisted profile (hokm.profile) on
signOut, and getProfile() reloads it — so after logout the previous user's
name/gender/avatar resurrected from localStorage. Now signOut clears the
in-memory + persisted profile, and the SignalR service also clears its mock
fallback so the post-logout guest profile is fresh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-13 09:17:49 +03:30
parent 53759be8b7
commit 78878efc22
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -341,8 +341,11 @@ export class MockOnlineService implements OnlineService {
async signOut() { async signOut() {
this.session = null; this.session = null;
if (isBrowser()) localStorage.removeItem(LS.session); this.profile = null; // forget the profile so the next sign-in / guest starts clean
// keep profile so progress persists across sign-ins on the same device if (isBrowser()) {
localStorage.removeItem(LS.session);
localStorage.removeItem(LS.profile);
}
} }
/* ----------------------------- profile ----------------------------- */ /* ----------------------------- profile ----------------------------- */
+1
View File
@@ -233,6 +233,7 @@ export class SignalrService implements OnlineService {
this.token = null; this.token = null;
this.cachedProfile = null; // drop the signed-in profile so it can't leak post-logout this.cachedProfile = null; // drop the signed-in profile so it can't leak post-logout
if (typeof window !== "undefined") localStorage.removeItem(LS_SESSION); if (typeof window !== "undefined") localStorage.removeItem(LS_SESSION);
await this.mock.signOut(); // also clear the guest/fallback profile (hokm.profile)
await this.conn?.stop(); await this.conn?.stop();
this.conn = null; this.conn = null;
} }