fix(auth): a member deletes nobody while the register is out of reach

A person still anonymous on a member was deleted there on the session
alone while the register was out of reach (the reading of the fixes' B1).
But the register may have linked them while their becoming identified on
the member failed, so with both failing, an account of the register's went
without its proof (the short reading's L2). A member now refuses every
deletion while it can't ask the register (decided by the developer on
21 Oct).

In the app, signing out of an anonymous account, which deletes it, signs
the device out all the same when the deletion fails, as a switch already
leaves one behind: the account is left to the instance's pruning of
anonymous accounts unused for 90 days. signInWays gets its doc comment
back.

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 17:49:27 +02:00
commit 634f2756d9
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 73 additions and 35 deletions

View file

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:halkyon_app/src/auth/data/auth_gateway.dart';
import 'package:halkyon_app/src/auth/data/sign_in_addresses.dart';
import 'package:halkyon_app/src/auth/model/auth_status.dart';
@ -32,11 +34,26 @@ class AuthRepository(
/// Signs out on this device. An anonymous account can never be signed into
/// again, so signing out of one deletes it with its progress (decided
/// 2026-09-30); the UI warns first.
Future<void> signOut() => switch (_gateway.status) {
SignedIn(isIdentified: false) => _gateway.deleteAccount(),
_ => _gateway.signOut(),
};
/// 2026-09-30); the UI warns first. Should deleting it fail (on a member
/// while the instance's register is out of reach, which deletes nobody
/// then: the short reading's L2), the device signs out all the same, as a
/// switch leaves one behind: the account is left to the instance's
/// pruning of anonymous accounts unused.
Future<void> signOut() async {
if (_gateway.status case SignedIn(isIdentified: false)) {
try {
await _gateway.deleteAccount();
return;
} on Exception catch (error, st) {
log(
'Deleting the anonymous account failed: ${error.runtimeType}',
name: 'Auth',
stackTrace: st,
);
}
}
await _gateway.signOut();
}
/// Deletes the signed-in person with everything they have, on the server
/// and all their devices; the UI asks first.

View file

@ -27,6 +27,10 @@ class FakeAuthGateway({var AuthStatus _status = const SignedOut()})
/// How often the signed-in person's account was deleted.
int accountDeletions = 0;
/// Thrown by the next deletions of the account while set, which then
/// delete nothing.
Exception? deletionError;
/// Whether the instance offers GitHub sign-in.
bool offersGitHub = true;
@ -79,6 +83,9 @@ class FakeAuthGateway({var AuthStatus _status = const SignedOut()})
@override
Future<void> deleteAccount() async {
accountDeletions++;
if (deletionError case final error?) {
throw error;
}
_set(const SignedOut());
}