/// <summary> /// Updates the user's profile. /// </summary> public async Task UpdatePasswordAsync(string id, UserPasswordVM vm) { await ValidateAsync(vm); var user = await FindAsync(id); var token = await _userMgr.GeneratePasswordResetTokenAsync(user); await _userMgr.ResetPasswordAsync(user, token, vm.Password); }
public ActionResult ResetPassword(UserPasswordVM user, string userEmail, string hash) { if (ModelState.IsValid) { service.ChangePassword(userEmail, user.Password); return(RedirectToAction("Index", "Home", new { message = $"{userEmail},{user.Password}" })); } else { return(RedirectToAction("PasswordRecovery", "User", new { Password = user.Password, ConfirmPassword = user.ConfirmPassword, userEmail = userEmail, hash = hash })); } }
/// <summary> /// Validates the user password. /// </summary> private Task ValidateAsync(UserPasswordVM vm) { if (string.IsNullOrEmpty(vm.Password) || string.IsNullOrEmpty(vm.PasswordConfirmation)) { throw new OperationException("Password cannot be empty."); } if (vm.Password != vm.PasswordConfirmation) { throw new OperationException("Passwords do not match."); } return(Task.CompletedTask); }
public ActionResult PasswordRecovery(UserPasswordVM user, string userEmail, string hash) { if (service.GetByKey(userEmail) == null || HashService.GenerateUserHash(service.GetByKey(userEmail)) != hash) { return(RedirectToAction("Index", "Home")); } else { ViewBag.Email = userEmail; ViewBag.Hash = hash; ViewBag.User = user; return(View()); } }
public Task Update(string id, [FromBody] UserPasswordVM vm) { return(_userMgr.UpdatePasswordAsync(id, vm)); }