public async Task <IActionResult> Index(string returnUrl) { var viewModel = await BuildViewModelAsync(returnUrl); if (viewModel != null) { var providers = await _totpService.GetProviders(User); foreach (var provider in providers) { _logger.LogDebug("Provider {Key}:{Value}", provider.Key, provider.Value); } return(View(nameof(Index), viewModel)); } return(View("Error")); }
/// <summary> /// Gets list of available providers for the given claims principal. /// </summary> /// <param name="service">The service to use.</param> /// <param name="userId">The user id.</param> public static Task <Dictionary <string, TotpProviderMetadata> > GetProviders(this ITotpService service, string userId) => service.GetProviders(new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(BasicClaimTypes.Subject, userId) })));