🐛 Recover the app when the session expires
A 401 mid-session made the PocketBase SDK drop the auth store, while session.userId and the gate of the layout stayed set: the user remained in the app, every round failed, /login was bounced back and a token-less pull was even taken for a successful round. The sync layer now ends the session through an onSessionExpired hook when a round fails with 401 or finds the auth store cleared, and reports no round as synced without a valid auth store. The session module tries one token refresh before it clears the session, and the layout resolves the gate again whenever the auth store is no longer valid, so the user lands on the login page and the next sign-in brings the data back.
This commit is contained in:
@@ -30,6 +30,7 @@ const mocks = vi.hoisted(() => {
|
||||
|
||||
vi.mock('$lib/pb', () => ({
|
||||
pb: {
|
||||
authStore: { isValid: true },
|
||||
autoCancellation: () => undefined,
|
||||
filter: (tpl: string, params: Record<string, unknown>) => tpl.replace(/\{:(\w+)\}/g, (_m, key: string) => JSON.stringify(String(params[key]))),
|
||||
collection: (name: string) => ({
|
||||
|
||||
Reference in New Issue
Block a user