public ActionResult ModifyPwd() { User user = GetCurrentUser(); UserEntity entity = new UserEntity() { USERID = user.USERID, USERNAME = user.USERNAME, ROLEID = user.ROLEID, DEPARTMENTID = user.DEPARTMENTID, MOBILEPHONE = user.MOBILEPHONE, EMAIL = user.EMAIL, USERSTATE = user.USERSTATE, PHONE = user.PHONE, ROLE = user.Role.ROLENAME, DEPARTMENT = user.Department.DEPARTMENTNAME }; return PartialView(entity); }
public ActionResult ModifyPwd(UserEntity model) { if (HttpContext.Request.Cookies["user"] != null) { User user = GetCurrentUser(); if (user.PASSWORD.Trim() != model.OldPassword) { return Content("<script >alert('旧密码错误,请输入!');window.history.go( -1 ); </script >", "text/html"); } if(string.IsNullOrEmpty(model.NewPassword)) { return Content("<script >alert('新密码不能为空,请输入!');window.history.go( -1 ); </script >", "text/html"); } user.PASSWORD = model.NewPassword.Trim(); db.Entry(user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return Content("<script >alert('密码修改成功!');window.history.go( -1 ); </script >", "text/html"); } return new RedirectResult("/Account/Login"); }