Skip to content

fix(auth): wipe form/session state on logout - #205

Open
arisu6804 wants to merge 1 commit into
QuickLendX:mainfrom
arisu6804:security/wipe-state-on-logout-71
Open

fix(auth): wipe form/session state on logout#205
arisu6804 wants to merge 1 commit into
QuickLendX:mainfrom
arisu6804:security/wipe-state-on-logout-71

Conversation

@arisu6804

Copy link
Copy Markdown

Closes #71

Threat model

No logout affordance existed yet -- signing out only means the session cookie expires server-side. On a shared/kiosk device, anything left in localStorage/sessionStorage (a cached session, an in-progress form draft) would still be readable by the next person to use the browser, even after the account owner believes they've signed out.

Summary

Adds logout() to useSession:

  • Clears the module-level session cache (so the next mount re-fetches instead of showing the previous user's cached session).
  • Clears every key in localStorage and sessionStorage, rather than trying to enumerate every form that might have persisted a draft -- a new form added later doesn't need this file updated to be covered.

Tests

lib/hooks/useSession.test.ts: seeds both storages, calls logout(), asserts both are empty and that a subsequent mount re-fetches (does not reuse the wiped cache).

Verification

npx vitest run lib/hooks/useSession.test.ts -- 5/5 passing. Full suite (npx vitest run, 164/164), npx tsc --noEmit, npx eslint . all clean.

Adds logout() to useSession: clears the module-level session cache and
every localStorage/sessionStorage key -- not just ones this module
knows about -- rather than trying to enumerate every form that might
have persisted a draft. A shared/kiosk device signing out must not
leave a later user able to read a prior session's cached data or an
in-progress form draft.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harden wipe form state on logout

1 participant