public async Task <ActionResult <TwoFactorInfo> > GetTwoFactorInfo() { try { var user = await _userManager.FindByNameAsync(User.Identity.Name); if (user == null) { throw new Exception("User is null"); } var twoFactorInfo = new TwoFactorInfo { HasAuthenticator = await _userManager.GetAuthenticatorKeyAsync(user) != null, Is2faEnabled = await _userManager.GetTwoFactorEnabledAsync(user), IsMachineRemembered = await _signInManager.IsTwoFactorClientRememberedAsync(user), RecoveryCodesLeft = await _userManager.CountRecoveryCodesAsync(user), }; return(Ok(twoFactorInfo)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private async Task GetTwoFactorInfoAsync() { TwoFactorInfo = await ApplicationUserService.GetTwoFactorInfoAsync(HttpClient); }
private async Task GetTwoFactorInfoAsync() { var client = await HttpClientHelper.CreateClientAsync(NavigationManager, HttpClientFactory, JSRuntime, Logger); TwoFactorInfo = await ApplicationUserService.GetTwoFactorInfoAsync(client); }