public async Task <ResetAuthenticatorModel> ResetAuthenticator(ResetAuthenticatorModel model) { var user = await GetUser(model.UserId, model); if (user == null) { return(LogErrorReturnModel(model)); } var set2FaResult = await _userManager.SetTwoFactorEnabledAsync(user, false); if (!set2FaResult.Succeeded) { model.Errors = set2FaResult.Errors.ToList(); LogErrors(model, "Failed to enable two factor authentication."); return(model); } var resetResult = await _userManager.ResetAuthenticatorKeyAsync(user); if (!resetResult.Succeeded) { model.Errors = resetResult.Errors.ToList(); LogErrors(model, "Failed to reset authenticator key."); } return(model); }
public async Task <IActionResult> ResetAuthenticator() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } var model = new ResetAuthenticatorModel(); model.StatusMessage = StatusMessage; return(View(model)); }
// ReSharper disable once UnusedParameter.Global public async Task <IActionResult> ResetAuthenticator(ResetAuthenticatorModel model) { model.UserId = UserId; model = await _manageEndpoint.ResetAuthenticatorAsync(model); if (HasErrors(model)) { return(View(model)); } _logger.LogInformation("User with ID '{UserId}' has reset their authentication app key.", model.UserId); var enableAuthenticatorModel = new EnableAuthenticatorModel { StatusMessage = "Your authenticator app key has been reset, you will need to configure your authenticator app using the new key." }; return(RedirectToAction("EnableAuthenticator", "Manage", enableAuthenticatorModel)); }
public async Task <IActionResult> ResetAuthenticator(ResetAuthenticatorModel model) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } await _userManager.SetTwoFactorEnabledAsync(user, false); await _userManager.ResetAuthenticatorKeyAsync(user); _logger.LogInformation("User with ID '{UserId}' has reset their authentication app key.", user.Id); await _signInManager.RefreshSignInAsync(user); StatusMessage = "Your authenticator app key has been reset, you will need to configure your authenticator app using the new key."; return(RedirectToAction("EnableAuthenticator")); }
public async Task <ResetAuthenticatorModel> ResetAuthenticatorAsync(ResetAuthenticatorModel model) { return(await _apiHelper.PostAsync(model, "api/Account/Manage/ResetAuthenticator")); }