예제 #1
0
        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));
            }
        }
예제 #2
0
 private async Task GetTwoFactorInfoAsync()
 {
     TwoFactorInfo = await ApplicationUserService.GetTwoFactorInfoAsync(HttpClient);
 }
예제 #3
0
        private async Task GetTwoFactorInfoAsync()
        {
            var client = await HttpClientHelper.CreateClientAsync(NavigationManager, HttpClientFactory, JSRuntime, Logger);

            TwoFactorInfo = await ApplicationUserService.GetTwoFactorInfoAsync(client);
        }