public async Task <ActionResult> ChangeUserPassword(string id, AdminUserChangePasswordViewModel model) { User user = this.users.GetUser(id).FirstOrDefault(); IdentityResult result = await userManager.RemovePasswordAsync(user); if (result.Succeeded) { result = await userManager.AddPasswordAsync(user, model.NewPassword); } TempData.AddSuccessMessage($"Password for {user.UserName} changed successfuly."); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> ChangeUserPassword(string id) { User user = this.users.GetUser(id).FirstOrDefault(); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{userManager.GetUserId(User)}'."); } bool hasPassword = await userManager.HasPasswordAsync(user); AdminUserChangePasswordViewModel model = new AdminUserChangePasswordViewModel(); return(View(model)); }