--- task: Fix homepage fragment persisting from previous login when switching account types cycles: 5 context: true private: false started: 2026-05-17T16:22:34Z finished: 2026-05-17T16:24:00Z --- ## files - resources/js/stores/user.js [lines 63-95] — fetchCurrentUser() has a guard that skips role re-fetch when acctType is already set; this allows stale sessionStorage role to persist - resources/js/Pages/Home.vue [lines 1-21] — renders role fragments before userStore loading is complete, causing flash of wrong fragment - resources/js/composables/Core/useAuth.js [lines 7-53] — module-level globalRole ref; module-level fetchRole() guard prevents re-fetch when sessionStorage already has a non-public role - resources/js/Pages/Auth/Login.vue [lines 13-38] — sessionStorage.clear() in onMounted runs synchronously, but app.js fetchCurrentUser() is async and can set sessionStorage AFTER the clear ## steps ### Step 1 — Fix stale-role guard in `fetchCurrentUser()` (user.js:78-84) The guard `if (!this.acctType || this.acctType === 'public')` prevents re-fetching the real server-side role when `acctType` is already populated from sessionStorage. This is the primary bug: after login, if sessionStorage has the old user's role (e.g. 'ultimate'), `acctType` initialises to 'ultimate' from the store state factory, the guard is false, and the role is never corrected against the server — even though the session now belongs to a completely different user. Remove the guard entirely so that `fetchCurrentUser()` **always** re-fetches `acct_type` from `/get/user/acct-type` after successfully loading the user object. ```js // user.js – fetchCurrentUser(), after setting this.user: // REMOVE the `if (!this.acctType || this.acctType === 'public')` wrapper. // Always fetch and overwrite acctType from the server. const resRole = await axios.get('/get/user/acct-type') if (resRole.data && resRole.data.acct_type) { this.acctType = resRole.data.acct_type sessionStorage.setItem('user_acct_type', this.acctType) } ``` Keep the 401/419 catch path unchanged — it already sets `acctType = 'public'`. ### Step 2 — Add loading guard to Home.vue before rendering role fragments While `userStore.loading` is true (fetchCurrentUser in flight), `userStore.acctType` may still hold the stale sessionStorage value. Guard all role-specific `