public ActionResult ChangePassword(UserAccess model) { if (ModelState.IsValid) { var uacnew = new UserAccess(); var readuser = uacnew.Read(model.UserID); uacnew.UserID = model.UserID; uacnew.Salt = System.DateTime.Now.Hour.ToString(); uacnew.Password = model.PasswordRetype; // Check if current password match // UserAccess ua = new UserAccess(); ua.UserID = model.UserID; ua.Read(model.UserID); var userAuthenticate = ua.AuthenticateUser(model.UserID, model.Password); if (userAuthenticate.ReturnCode == 0001 && userAuthenticate.ReasonCode == 0001) { if (model.PasswordRetype != model.ConfirmPassword) { ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); return(View(model)); } var response = BUSUserAccess.SavePassword(uacnew); return(RedirectToAction("ChangePasswordSuccess")); } ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); return(View(model)); } // If we got this far, something failed, redisplay form return(View(model)); }
private void btnResetPassword_Click(object sender, EventArgs e) { var uacnew = new UserAccess(); var readuser = uacnew.Read(txtUserID.Text); uacnew.UserID = txtUserID.Text; uacnew.Salt = System.DateTime.Now.Hour.ToString(); uacnew.Password = txtPassword.Text; if (txtPassword.Text != txtNewPassword.Text) { MessageBox.Show("Passwords do not match."); return; } var response = BUSUserAccess.SavePassword(uacnew); ControllerUtils.ShowFCMMessage(response.UniqueCode, Utils.UserID); // Refresh list // ListRoles(); ListUserRoles(); }