feat(auth): add account switcher to the user menu #44
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!44
Loading…
Reference in a new issue
No description provided.
Delete branch "t3code/switch-accounts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the account switching feature request: let a signed-in user authenticate additional accounts (e.g. a bot account) and toggle between them from the user dropdown without a full logout/login cycle.
How it works
switch_accounts), so it cannot be forged by the client; a switch is only ever permitted to an account previously authenticated in that session.switch_addflag and redirects to the normal sign-in flow. The flag lets the still-signed-in user reach the login/2FA routes (which normally require being signed out) and is preserved across the several session regenerations of the sign-in flow, including 2FA.uid, keeping the account list.Changes
routers/web/auth/account_switch.go(new) — session helpers, add/switch/remove handlers, and the navbar middleware.routers/web/auth/auth.go— preserve the switcher keys across session regeneration; record the account into the switcher on sign-in; show the login form in add-account mode.routers/web/web.go— routes under/user/account_switch/*,reqSignOutbypass while adding an account, navbar middleware registration.templates/base/head_navbar.tmpl+head_navbar_switch_accounts.tmpl(new) — dropdown UI; not shown in the restrictedHideNavbarLinksstate.templates/user/auth/signin_inner.tmpl— hint shown while adding an account.options/locale/locale_en-US.ini— new strings.tests/integration/account_switch_test.go(new) — end-to-end tests for the plain flow and the 2FA add-account path.Tests
TestAccountSwitchandTestAccountSwitchWith2FApass; no regressions in the auth-adjacent integration tests.WIP: feat(auth): add account switcher to the user menuto feat(auth): add account switcher to the user menu