Пример #1
0
        public ActionResult UpdatePwd(UpdatePwdModel model)
        {
            if (model.NewPwd != model.ConfigPwd)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "两次新密码不一致" })));
            }
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            int       userId           = HttpContext.AppUserId();
            Tapp_User appUser          = ctx.Tapp_User.FirstOrDefault(c => c.Id == userId && c.State == 1);

            if (appUser == null)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "用户不存在" })));
            }
            string oldPwdDb = Md5.Encrypt(appUser.UserName + model.OldPwd);

            if (oldPwdDb != appUser.UserPwd)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "旧密码错误" })));
            }
            appUser.UserPwd = Md5.Encrypt(appUser.UserName + model.NewPwd);
            if (ctx.SaveChanges() >= 0)
            {
                return(Content(this.GetJSON(new { Result = true, Msg = "修改密码成功" })));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "修改密码失败" })));
        }
Пример #2
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            RightHeper rightHelper = new RightHeper();

            ViewBag.Menus   = rightHelper.LoadMenu(HttpContext.AppUserId());
            ViewBag.AppUser = this.AppUser();
            return(View());
        }