fix(auth): wipe form/session state on logout - #205
Open
arisu6804 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()touseSession:localStorageandsessionStorage, 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, callslogout(), 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.