listFactors method

Returns the list of MFA factors enabled for this user.

Automatically refreshes the session to get the latest list of factors.

Implementation

Future<AuthMFAListFactorsResponse> listFactors() async {
  await _client.refreshSession();
  final user = _client.currentUser;
  final factors = user?.factors ?? [];
  final totp = factors
      .where((factor) =>
          factor.factorType == FactorType.totp &&
          factor.status == FactorStatus.verified)
      .toList();

  return AuthMFAListFactorsResponse(all: factors, totp: totp);
}