deleteAccount method
Deletes the account. confirmed is the person's explicit confirmation,
and nothing is sent without it; the server also asks for the
password, and a code or recoveryCode when there is a second
factor, then hands the person to the project's Data Compliance erasure
where one is configured. The device signs out once the server confirms.
Implementation
Future<DateTime?> deleteAccount({
required String password,
required bool confirmed,
String? code,
String? recoveryCode,
}) {
if (!confirmed) {
throw ArgumentError.value(
confirmed, 'confirmed', 'Deleting an account needs explicit confirmation');
}
// When the account will be erased, for a deletion waiting out the
// project's grace period -- signing in before then keeps it -- and null
// for one erased at once.
return _sessionClient
.deleteAccount(password: password, code: code, recoveryCode: recoveryCode)
.then((DateTime? erasesAt) {
_currentUser = null;
return erasesAt;
});
}