deleteAccount method

Future<void> deleteAccount()

Deletes the currently authenticated MyUser account.

Implementation

Future<void> deleteAccount() async {
  code.error.value = null;
  password.error.value = null;

  try {
    await _myUserService.deleteMyUser(
      confirmation: code.text.isNotEmpty ? ConfirmationCode(code.text) : null,
      password: password.text.isNotEmpty ? UserPassword(password.text) : null,
    );
  } on DeleteMyUserException catch (e) {
    code.error.value = e.toMessage();
    password.error.value = e.toMessage();
  } on FormatException {
    code.error.value = 'err_wrong_code'.l10n;
    password.error.value = 'err_wrong_code'.l10n;
  } catch (e) {
    code.error.value = 'err_data_transfer'.l10n;
    password.error.value = 'err_data_transfer'.l10n;
    rethrow;
  }
}