public async Task <IActionResult> TwoFactorAuthentication() { ViewData["Title"] = sr["Two-factor authentication"]; var user = await userManager.FindByIdAsync(User.GetUserId()); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{userManager.GetUserId(User)}'."); } var model = new TwoFactorAuthenticationViewModel { HasAuthenticator = await userManager.GetAuthenticatorKeyAsync(user) != null, Is2faEnabled = user.TwoFactorEnabled, RecoveryCodesLeft = await userManager.CountRecoveryCodesAsync(user), }; return(View(model)); }