Skip to content

fix(phx.gen.auth): delete old token when reissuing session#6657

Open
otlaitil wants to merge 1 commit intophoenixframework:mainfrom
otlaitil:fix/phx-gen-auth-reissue-session-token
Open

fix(phx.gen.auth): delete old token when reissuing session#6657
otlaitil wants to merge 1 commit intophoenixframework:mainfrom
otlaitil:fix/phx-gen-auth-reissue-session-token

Conversation

@otlaitil
Copy link
Copy Markdown

Fixes a bug where reissuing user session token leaves the old token in the database. This bloats the database table and poses a minor security risk as old token will remain valid.

The fix copies the pattern from logout to clear the token

Steps to reproduce

  1. Run auth scaffold mix phx.gen.auth Accounts User users
  2. In user_auth.ex set @session_reissue_age_in_days 0
  3. Register a user and log in
  4. Check tokens with SELECT * FROM users_tokens;
  5. Refresh the page
  6. Check tokens again (tokens accumulate)

Fixes a bug where reissuing user session token leaves the old token to database.
This bloats the database table and poses a minor security risk as old token will
remain valid.
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.

1 participant