Beispiel #1
0
        public JsonResult ChangePassword(Eme.Model.Entity.ChangePasswordModel model)
        {
            var currUser = UserBLL.GetUserById(LoginUserManager.CurrLoginUser.UserId);
            var msg = string.Empty;
            var result = false;

            if (
                !Utility.SecurityHelper.GetMd5(model.OldPassword)
                    .Equals(currUser.Password, StringComparison.CurrentCultureIgnoreCase))
            {
                msg = "原始密码错误!";
                result = false;
            }
            else
            {
                result = UserBLL.ChangePassword(LoginUserManager.CurrLoginUser.UserId, Utility.SecurityHelper.GetMd5(model.NewPassword));
            }

            //beta 2015.06.10   密码修改成功后调用爽哥接口,将新密码同步至爽哥
            var branchParents = ConfigHelper.GetAppSettingValue("OpenBranchParentIds").ToString();
            var openBranchParentIds = branchParents.Split(new[] { ',' }).Select(p => int.Parse(p)).ToList<int>();
            var currBranch = BranchBLL.GetCurrentBranchListByUserId(currUser.Id);
            //修改密码成功、是学员、并且包括在设定的区域中心之中
            if (result && currUser.UserType == ConvertEnum.UserTypeForStudent && openBranchParentIds.Contains(currBranch.ParentId.Value))
            {
                ICoolBrotherApi coolApi = new CoolBrotherApi();
                coolApi.SyncStudentByUserId(currUser.Id);
            }

            return Json(new { Status = result, Msg = msg }, JsonRequestBehavior.DenyGet);
        }
Beispiel #2
0
        public ActionResult Login(Eme.Model.Entity.AccountModel model)
        {
            if (!ModelState.IsValid)
            { return View(model); }

            if (Request.Cookies[Global.CheckCodeKey] != null)
            {
                if (!LoginUserManager.IsCheckCode(model.CheckCode))
                {
                    ViewBag.Tiper = new FunctionResult()
                    {
                        Status = false,
                        Info = "验证码错误!",
                        ReturnValue = null
                    };
                    return View(model);
                }
                //验证码使用完后,清除。
                Request.Cookies[Global.CheckCodeKey].Expires = DateTime.Now.AddDays(-1);
            }
            else
            {
                ViewBag.Tiper = new FunctionResult()
                {
                    Status = false,
                    Info = "验证码已过期!",
                    ReturnValue = null
                };
                return View(model);
            }

            //验证账号、密码
            var result = UserBLL.UserLoginValidate(model.UserName, SecurityHelper.GetMd5(model.Password), Enum.UserType.Student);
            if (result.Status)
            {
                LoginUserCache.UpdateLoginUserCacheForLogin(result.ReturnValue.ToString());
                var loginUser = LoginUserCache.GetLoginUserCacheByKey(result.ReturnValue.ToString());
                if (loginUser == null)
                {
                    ViewBag.Tiper = new FunctionResult()
                    {
                        Status = false,
                        Info = "登录异常,请与管理员联系!",
                        ReturnValue = null
                    };
                    return View(model);
                }

                // 标记V3 Token 全国上线后,去掉
                Session["V3Token"] = SecurityHelper.Encrypt(SecurityHelper.Encrypt(string.Format("{0}|{1}", model.UserName, model.Password), DateTime.Now.ToString("yyyyMMdd")), "8FDD12E1-FA35-43E7-83EF-E84DE7CF9531");

                LoginUserManager.SignLoginUser(loginUser);
                return RedirectToAction("Index", "Home");

            }
            ViewBag.Tiper = result;
            return View(model);
        }