Skip to content

feat: Multi account sessions#296

Open
3kh0 wants to merge 4 commits into
hackclub:mainfrom
3kho:multi-account-sessions
Open

feat: Multi account sessions#296
3kh0 wants to merge 4 commits into
hackclub:mainfrom
3kho:multi-account-sessions

Conversation

@3kh0

@3kh0 3kh0 commented Jul 25, 2026

Copy link
Copy Markdown
Member

When users have more than one HCA account for one reason or another, switching accounts is downright annoying. This adds a account switcher seen in indie services like Google.

3kh0 and others added 4 commits July 24, 2026 22:12
auth_time_from_resource_owner picked `sessions.not_expired.order(created_at:
:desc).first` — the newest session for the identity, not the one that actually
authorized the request. Same bug in reauthenticate_resource_owner. Both blocks
also used `return`, which raises LocalJumpError under instance_exec.

Threads the real session through instead:

  - Current.identity_session, set from ApplicationController per request
  - oauth_access_grants.source_session_id stamped at authorization time (the
    column and FK already existed in schema, unwritten)
  - at code exchange the grant's session is attached to the IdToken, since the
    token endpoint has no session cookie
  - auth_time returns nil when neither source is available rather than guessing

Prerequisite for per-account authentication assurance once a browser can hold
more than one signed-in account.

Co-authored-by: 24c02 <163450896+24c02@users.noreply.github.com>
Co-authored-by: 24c02 <163450896+24c02@users.noreply.github.com>
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