public ActionResult ChangePassUser(ChangePasswordUserVM changePassword, string returnUrl) { if (!ModelState.IsValid) { return(View(changePassword)); } //if (changePassword.UserName == null || changePassword.CurrentPassword == null || changePassword.NewPassword == null || changePassword.ConfirmPassword == null || changePassword.UserName.Trim().Equals("") || changePassword.CurrentPassword.Trim().Equals("") || changePassword.NewPassword.Trim().Equals("") || changePassword.ConfirmPassword.Trim().Equals("")) //{ // ModelState.AddModelError("", "Wrong Username or Password"); //} List <User> appusers = db.User.ToList(); foreach (var appuser in appusers) { if (appuser.UserName.Equals(changePassword.UserName)) { appuser.Password = encryptionDecryptionUtil.CreatePasswordHash(changePassword.NewPassword, appuser.Salt); db.Entry(appuser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ListUser")); } } if (ModelState.IsValid) { ModelState.AddModelError("", "Wrong Username or Password"); } return(View(changePassword)); }
public Result <User> ChangePassword([FromBody] ChangePasswordUserVM changePasswordUserVM) { var user = new User() { Password = changePasswordUserVM.OldPassword }; return(_userService.ChangeUserPassword(user, changePasswordUserVM.NewPassword)); }
public Result <User> ChangePassword([FromBody] ChangePasswordUserVM changePasswordUserVM) { var user = new User() { Password = changePasswordUserVM.OldPassword }; user.Id = new Guid(Thread.CurrentPrincipal?.Identity?.Name); return(_userService.ValidOldPasswordAndChangeUserPassword(user, changePasswordUserVM.NewPassword)); }