protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string oldpass = Request.Form["oldpass"]; string newpass = Request.Form["newpass"]; MyCreek.Platform.Users busers = new MyCreek.Platform.Users(); var user = MyCreek.Platform.Users.CurrentUser; if (user != null) { if (string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), oldpass.Trim()), false) != 0) { MyCreek.Platform.Log.Add("修改密码失败", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码失败,旧密码错误!"), MyCreek.Platform.Log.Types.用户登录); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('旧密码错误!');", true); } else { busers.UpdatePassword(newpass.Trim(), user.ID); MyCreek.Platform.Log.Add("修改密码成功", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码成功!"), MyCreek.Platform.Log.Types.用户登录); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('密码修改成功!');new RoadUI.Window().close();", true); } } } }
public ActionResult EditPass(FormCollection collection) { string oldpass = Request.Form["oldpass"]; string newpass = Request.Form["newpass"]; MyCreek.Platform.Users busers = new MyCreek.Platform.Users(); var user = MyCreek.Platform.Users.CurrentUser; if (user != null) { if (string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), oldpass.Trim()), false) != 0) { MyCreek.Platform.Log.Add("修改密码失败", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码失败,旧密码错误!"), MyCreek.Platform.Log.Types.用户登录); ViewBag.Script = "alert('旧密码错误!');"; } else { busers.UpdatePassword(newpass.Trim(), user.ID); MyCreek.Platform.Log.Add("修改密码成功", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码成功!"), MyCreek.Platform.Log.Types.用户登录); ViewBag.Script = "alert('密码修改成功!');new RoadUI.Window().close();"; } } return(View()); }