deleteAnonymousUser method

Future<void> deleteAnonymousUser({
  1. required AuthUser user,
})

Deletes anonymous user.

Implementation

Future<void> deleteAnonymousUser({required AuthUser user}) async {
  _ensureConfigured();
  if (!user.isAnonymous) throw AuthFlowException('anonymous_required');
  if (disableDeleteAnonymousUser) {
    throw AuthFlowException('anonymous_delete_disabled');
  }
  final result = await _mutationStore.deleteAnonymousAccount(
    AuthAnonymousDeleteAccountCommand(
      operationId: hashOpaqueToken('anonymous-delete:${user.id}'),
      userId: user.id,
    ),
  );
  switch (result.status) {
    case AuthAnonymousMutationStatus.applied:
    case AuthAnonymousMutationStatus.replayed:
      return;
    case AuthAnonymousMutationStatus.notAnonymous:
      throw AuthFlowException('anonymous_required');
    case AuthAnonymousMutationStatus.notFound:
      throw AuthFlowException('anonymous_user_not_found');
    case AuthAnonymousMutationStatus.replayMismatch:
      throw AuthFlowException('anonymous_delete_unavailable');
  }
}