fix(auth): link sign-up accounts and let removing them stop sign-in (v17) #256
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!256
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/oauth-account-links-v17"
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?
Port of arbinel#31 and arbinel#32 to v17, which runs on codefloe.com until the move to Arbinel. Fixes the problem reported in https://forum.codefloe.com/t/github-linking-bug/237.
Problem
A user who signed up with GitHub saw an empty Linked accounts list, and clicking Link account only signed them in again and sent them to the dashboard, with no link and no message.
Sign-up stored the identity on the user but never inserted the
external_login_userrow that list reads (forgejo#11857).Every OAuth2-registered account on codefloe.com was missing its row, and those have since been backfilled.
The backfill also made Remove visible on those accounts, and that button deleted only the row.
Sign-in also matches the identity on the user, so the provider kept signing them in.
Fix
routers/web/auth/auth.go:handleUserCreatedcallsLinkAccountToUserinstead ofUpdateExternalUser, which only updates a row that already exists. This covers auto-registration and/user/link_account_signup.routers/web/user/setting/security/security_codefloe.go: removing the link to the source a user signed up with also clearslogin_type,login_sourceandlogin_name, making the account a local one.Testing
Run on this branch, not only on Arbinel.
TestSignUpViaOAuthCreatesAccountLinkfails on both sign-up paths without the fix.TestRemoveSignUpAccountLinkfails in the three cases that change behaviour without the fix; the fourth covers behaviour that stays the same.make lint-backendpasses with the pinned Go 1.26.10.Created with Opus 5.5 in Claude Code.
c30df971ac20d7fe6488