fix(auth): GitHub's end deletes what it says, when it says
An account deleted at GitHub's end whose host step after the deletion's transaction failed counts as deleted, its GitHub ID gone with it, not as one to try again (the short reading). The app's text for an account that signs in with GitHub alone named the end as the day it would be deleted; it is deleted 30 days later (gitHubAccountsKeptAfterEnd), which the text now says, in English and German. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
634f2756d9
commit
a9bbda7017
7 changed files with 43 additions and 9 deletions
|
|
@ -233,6 +233,6 @@
|
|||
"passwordResetsCallOff": "Absagen",
|
||||
"passwordCallOffTitle": "Zurücksetzen absagen",
|
||||
"passwordCallOffIntro": "Dein Passwort und ein Code sagen jedes anstehende Zurücksetzen ab.",
|
||||
"passwordSectionGitHubEndsDeletes": "Die Anmeldung mit GitHub endet am {date}. Dann wird dein Konto mit allem darin gelöscht, es sei denn, du richtest vorher ein Passwort ein.",
|
||||
"passwordSectionGitHubEndsDeletes": "Die Anmeldung mit GitHub endet am {date}. Richte bis dahin ein Passwort ein: Ein Konto ohne wird 30 Tage später mit allem darin gelöscht.",
|
||||
"passwordSignedInBefore": "Nur ein seitdem angemeldetes Gerät kann diese Warnung ausblenden: Melde dich auf diesem neu an oder ändere dein Passwort."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -518,7 +518,7 @@
|
|||
"passwordResetsCallOff": "Call it off",
|
||||
"passwordCallOffTitle": "Call off the reset",
|
||||
"passwordCallOffIntro": "Your password and a code call off every reset waiting.",
|
||||
"passwordSectionGitHubEndsDeletes": "Sign-in with GitHub ends on {date}. Your account, with everything in it, will be deleted then, unless you set up a password before.",
|
||||
"passwordSectionGitHubEndsDeletes": "Sign-in with GitHub ends on {date}. Set up a password before then: an account without one is deleted 30 days later, with everything in it.",
|
||||
"@passwordSectionGitHubEndsDeletes": {
|
||||
"placeholders": {
|
||||
"date": {
|
||||
|
|
|
|||
|
|
@ -1504,7 +1504,7 @@ abstract class HalkyonAppLocalizations {
|
|||
/// No description provided for @passwordSectionGitHubEndsDeletes.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Sign-in with GitHub ends on {date}. Your account, with everything in it, will be deleted then, unless you set up a password before.'**
|
||||
/// **'Sign-in with GitHub ends on {date}. Set up a password before then: an account without one is deleted 30 days later, with everything in it.'**
|
||||
String passwordSectionGitHubEndsDeletes(String date);
|
||||
|
||||
/// No description provided for @passwordSignedInBefore.
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ class HalkyonAppLocalizationsDe extends HalkyonAppLocalizations {
|
|||
|
||||
@override
|
||||
String passwordSectionGitHubEndsDeletes(String date) {
|
||||
return 'Die Anmeldung mit GitHub endet am $date. Dann wird dein Konto mit allem darin gelöscht, es sei denn, du richtest vorher ein Passwort ein.';
|
||||
return 'Die Anmeldung mit GitHub endet am $date. Richte bis dahin ein Passwort ein: Ein Konto ohne wird 30 Tage später mit allem darin gelöscht.';
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -861,7 +861,7 @@ class HalkyonAppLocalizationsEn extends HalkyonAppLocalizations {
|
|||
|
||||
@override
|
||||
String passwordSectionGitHubEndsDeletes(String date) {
|
||||
return 'Sign-in with GitHub ends on $date. Your account, with everything in it, will be deleted then, unless you set up a password before.';
|
||||
return 'Sign-in with GitHub ends on $date. Set up a password before then: an account without one is deleted 30 days later, with everything in it.';
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ final _endsOf = Expando<DateTime>('GitHub sign-in ends');
|
|||
/// How long after GitHub sign-in ended ([gitHubSignInEnds]) the accounts
|
||||
/// that signed in with it alone and every GitHub ID are kept before they
|
||||
/// are deleted ([forgetGitHubAccounts]): a date the operator set wrong can
|
||||
/// be put right meanwhile, before anything is lost.
|
||||
/// be put right meanwhile, before anything is lost. The app's texts name it
|
||||
/// (halkyon_app's `passwordSectionGitHubEndsDeletes`): change them with it.
|
||||
const gitHubAccountsKeptAfterEnd = Duration(days: 30);
|
||||
|
||||
/// Deletes every GitHub ID the instance keeps once GitHub sign-in has ended
|
||||
|
|
@ -124,13 +125,23 @@ Future<int> forgetGitHubAccounts(
|
|||
try {
|
||||
await deletePerson(session, person, tellMembers: false);
|
||||
} on Object catch (error) {
|
||||
// A step after its transaction may have failed, the account gone
|
||||
// with its GitHub ID all the same (the short reading): only one
|
||||
// still here is tried again.
|
||||
// SELECT … FROM "serverpod_auth_core_user" WHERE "id" = $1
|
||||
final gone = await AuthUser.db.findById(session, person) == null;
|
||||
// Its type only: whose stays out of the log.
|
||||
session.log(
|
||||
'Deleting an account that signed in with GitHub alone failed: '
|
||||
'${error.runtimeType}; tried again tomorrow.',
|
||||
gone
|
||||
? 'Deleted an account that signed in with GitHub alone, but a '
|
||||
'step after failed: ${error.runtimeType}.'
|
||||
: 'Deleting an account that signed in with GitHub alone '
|
||||
'failed: ${error.runtimeType}; tried again tomorrow.',
|
||||
level: LogLevel.warning,
|
||||
);
|
||||
failed.add(person);
|
||||
if (!gone) {
|
||||
failed.add(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
session.log(
|
||||
|
|
|
|||
|
|
@ -328,6 +328,29 @@ void main() {
|
|||
expect(notifier.told.toSet(), {dana, emil});
|
||||
});
|
||||
|
||||
test('an account deleted whose step afterwards failed counts as '
|
||||
'deleted, not as one to try again (the short reading)', () async {
|
||||
useBase(
|
||||
sessionBuilder,
|
||||
deletePersonData: [
|
||||
(session, person, transaction) => Future.value(
|
||||
() => Future<void>.error(StateError('cleaning up failed')),
|
||||
),
|
||||
],
|
||||
);
|
||||
final ends = DateTime.utc(2027, 1, 22);
|
||||
useGitHubSignInEnds(session.serverpod, ends);
|
||||
|
||||
final forgotten = await forgetGitHubAccounts(
|
||||
session,
|
||||
now: ends.add(gitHubAccountsKeptAfterEnd),
|
||||
);
|
||||
|
||||
expect(await AuthUser.db.findById(session, ben), isNull);
|
||||
expect(await GitHubAccount.db.count(session), 0);
|
||||
expect(forgotten, 1);
|
||||
});
|
||||
|
||||
test('at its end keeps the account of someone with an address too, '
|
||||
'forgetting only the GitHub ID', () async {
|
||||
final carl = (await AuthServices.instance.authUsers.create(
|
||||
|
|
|
|||
Loading…
Reference in a new issue