From 78878efc222422b5035d561e92249106153c9a8d Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Sat, 13 Jun 2026 09:17:49 +0330 Subject: [PATCH] fix(auth): fully clear profile on logout (no stale name/gender after sign-out) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/lib/online/mock-service.ts | 7 +++++-- src/lib/online/signalr-service.ts | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/online/mock-service.ts b/src/lib/online/mock-service.ts index c9d60c3..faad015 100644 --- a/src/lib/online/mock-service.ts +++ b/src/lib/online/mock-service.ts @@ -341,8 +341,11 @@ export class MockOnlineService implements OnlineService { async signOut() { this.session = null; - if (isBrowser()) localStorage.removeItem(LS.session); - // keep profile so progress persists across sign-ins on the same device + this.profile = null; // forget the profile so the next sign-in / guest starts clean + if (isBrowser()) { + localStorage.removeItem(LS.session); + localStorage.removeItem(LS.profile); + } } /* ----------------------------- profile ----------------------------- */ diff --git a/src/lib/online/signalr-service.ts b/src/lib/online/signalr-service.ts index c0a9867..804fefc 100644 --- a/src/lib/online/signalr-service.ts +++ b/src/lib/online/signalr-service.ts @@ -233,6 +233,7 @@ export class SignalrService implements OnlineService { this.token = null; this.cachedProfile = null; // drop the signed-in profile so it can't leak post-logout if (typeof window !== "undefined") localStorage.removeItem(LS_SESSION); + await this.mock.signOut(); // also clear the guest/fallback profile (hokm.profile) await this.conn?.stop(); this.conn = null; }