public ActionResult SettingPassword(int id) { SettingPasswordViewModel model = new SettingPasswordViewModel(); model.Id = id; ViewBag.From = User.UserId; return(View(model)); }
public ActionResult ChangePassword(SettingPasswordViewModel postForm) { string response; bool change = settingsManager.ChangePassword(postForm, out response); if (change) { Session["updateMessage"] = response; return(RedirectToAction("Logout", "Account")); } else { Session["errorMessage"] = response; return(RedirectToAction("ChangePassword", "Settings")); } }
public ActionResult SettingPassword(SettingPasswordViewModel model, int from) { using (var unitWork = new UnitOfWork()) { var repo = unitWork.GetRepository <User>(); if (!ModelState.IsValid) { return(View(model)); } var user = repo.Get(t => t.Id == model.Id); user.Password = _encryptionService.EncryptPassword(model.NewPassword, user.Salt); repo.UpdateAndSubmit(user); } return(RedirectToAction("edit", "staff", new { id = model.Id })); }
public bool ChangePassword(SettingPasswordViewModel settingForm, out string outputMessage) { string emailAddress = HttpContext.Current.User.Identity.Name.ToString(); Account userAccount = global.GetAccount(emailAddress); if (userAccount != null) { string oldPassEncrypt = Crypto.SHA1(settingForm.OldPassword); string newPassEncrypt = Crypto.SHA1(settingForm.NewPassword); string newPassEncryptConfirm = Crypto.SHA1(settingForm.ConfirmNewPassword); if (userAccount.Password == oldPassEncrypt) { if (newPassEncrypt == newPassEncryptConfirm) { try { userAccount.Password = newPassEncrypt; db.SaveChanges(); outputMessage = string.Format(Resources.Processing.ProcessSettingsConfirmed, "password"); return(true); } catch { outputMessage = Resources.Processing.ProcessError; return(false); } } else { outputMessage = Resources.Processing.ProcessPasswordNoMatch; return(false); } } else { outputMessage = Resources.Processing.ProcessPasswordIncorrect; return(false); } } outputMessage = Resources.Processing.ProcessError; return(false); }
public SettingPasswordPage() { InitializeComponent(); ViewModel = new SettingPasswordViewModel(); }