codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

fix(auth): link sign-up accounts and let removing them stop sign-in (v17) #256

Merged
pat-s merged 1 commit from fix/oauth-account-links-v17 into v17.0/forgejo-codefloe 2026-11-06 20:23:17 +00:00
Owner

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_user row 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: handleUserCreated calls LinkAccountToUser instead of UpdateExternalUser, 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 clears login_type, login_source and login_name, making the account a local one.
  • That removal is refused when the user has no password and no link to another active source, because they would be locked out.
  • Removing any other link works as before.

Testing

Run on this branch, not only on Arbinel.

  • TestSignUpViaOAuthCreatesAccountLink fails on both sign-up paths without the fix.
  • TestRemoveSignUpAccountLink fails in the three cases that change behaviour without the fix; the fourth covers behaviour that stays the same.
  • 73 related integration tests pass on SQLite (OAuth, sign-up, sign-in, account switching, settings).
  • make lint-backend passes with the pinned Go 1.26.10.

Created with Opus 5.5 in Claude Code.

Port of [arbinel#31](https://codefloe.com/arbinel/arbinel/pulls/31) and [arbinel#32](https://codefloe.com/arbinel/arbinel/pulls/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_user` row that list reads ([forgejo#11857](https://codeberg.org/forgejo/forgejo/issues/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`: `handleUserCreated` calls `LinkAccountToUser` instead of `UpdateExternalUser`, 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 clears `login_type`, `login_source` and `login_name`, making the account a local one. - That removal is refused when the user has no password and no link to another active source, because they would be locked out. - Removing any other link works as before. ## Testing Run on this branch, not only on Arbinel. - `TestSignUpViaOAuthCreatesAccountLink` fails on both sign-up paths without the fix. - `TestRemoveSignUpAccountLink` fails in the three cases that change behaviour without the fix; the fourth covers behaviour that stays the same. - 73 related integration tests pass on SQLite (OAuth, sign-up, sign-in, account switching, settings). - `make lint-backend` passes with the pinned Go 1.26.10. Created with Opus 5.5 in Claude Code.
fix(auth): link sign-up accounts and let removing them stop sign-in (v17)
Some checks failed
testing / backend-checks (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (1/2) (pull_request) Has been cancelled
testing / test-e2e (2/2) (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
c30df971ac
Port of arbinel#31 and arbinel#32.

Signing up through an OAuth2 source stored the identity on the user but never
created the account link, so Linked accounts stayed empty and Link account only
signed the user in again. Create the link at sign-up.

Removing a link deleted only that row while sign-in also matches the identity
on the user. Clear the identity too, and refuse when that would leave the user
unable to sign in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pat-s force-pushed fix/oauth-account-links-v17 from c30df971ac
Some checks failed
testing / backend-checks (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (1/2) (pull_request) Has been cancelled
testing / test-e2e (2/2) (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
to 20d7fe6488
All checks were successful
testing / frontend-checks (pull_request) Successful in 2m7s
testing / test-unit (pull_request) Successful in 11m55s
testing / test-e2e (1/2) (pull_request) Successful in 3m47s
testing / test-pgsql (3/4) (pull_request) Successful in 14m42s
testing / test-pgsql (4/4) (pull_request) Successful in 17m38s
milestone / set (pull_request_target) Has been skipped
testing / backend-checks (pull_request) Successful in 11m50s
testing / test-pgsql (2/4) (pull_request) Successful in 9m47s
testing / test-e2e (2/2) (pull_request) Successful in 3m40s
testing / test-pgsql (1/4) (pull_request) Successful in 14m43s
issue-labels / backporting (pull_request_target) Has been skipped
2026-11-06 19:53:40 +00:00
Compare
pat-s scheduled this pull request to auto merge when all checks succeed 2026-11-06 19:56:32 +00:00
pat-s merged commit 24168aa6be into v17.0/forgejo-codefloe 2026-11-06 20:23:17 +00:00
pat-s deleted branch fix/oauth-account-links-v17 2026-11-06 20:23:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!256
No description provided.