fix(auth): a GitHub account someone has is theirs to switch to where passwords are offered too

Linking refused every GitHub account with `deprecated` where people sign in
with a password, before asking whether the account was someone else's. An
anonymous person tapping Sign in with GitHub, whose app links first and
switches to the account's person when it is taken, so never got to the
switch: the end-to-end test of 21 Oct found it. Nothing is linked either
way; the account someone has is said to be theirs first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-21 19:12:26 +02:00
commit 562d334e6e
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -194,6 +194,22 @@ void main() {
expect(await gitHubAccountToSignIn(session, '1001'), ben);
});
test(
"tells an anonymous person whose GitHub account is another's so, "
'as linking nothing, for the app to switch to that account',
() async {
usePasswordKeys(session.serverpod, testPasswordKeys);
EmailCodes.of(session.serverpod).mailer = const LogCodeMailer();
await expectLater(
linkGitHubAccount(session, authUserId: anna, gitHubUserId: '1001'),
throwsA(_refusal(GitHubSignInRefusal.takenByAnotherPerson)),
);
expect(await _isAnonymous(session, anna), isTrue);
expect(await gitHubAccountToSignIn(session, '1001'), ben);
},
);
test('signs nobody in and links nothing from the day it ends, after '
'which pruning forgets every GitHub ID', () async {
final ends = DateTime.utc(2027, 1, 22);