/// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        public JsonResult ChangePwd()
        {
            if (_Request == null)
            {
                _Request = Request;
            }
            SetRequest(_Request);
            UserInfo currUser = GetCurrentUser(_Request);

            if (currUser == null)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "您未登录系统或登录时间过长,请重新登录系统后再修改密码!"
                }));
            }
            string   errMsg       = string.Empty;
            string   oldPwd       = _Request.QueryEx("oldPwd").ObjToStr();
            string   newPwd       = _Request.QueryEx("newPwd").ObjToStr();
            UserInfo tempUserInfo = UserOperate.GetUserInfo(currUser.UserName, oldPwd, out errMsg);

            if (tempUserInfo == null)
            {
                return(Json(new ReturnResult()
                {
                    Success = false, Message = "您当前登录密码输入不正确,请重新输入!"
                }));
            }
            bool rs = UserOperate.ModifyPassword(currUser.UserId, newPwd, out errMsg);

            if (rs)
            {
                CommonOperate.ExecuteUserOperateHandleMethod("AfterChangePwd", new object[] { currUser.UserName, oldPwd, newPwd });
            }
            return(Json(new ReturnResult()
            {
                Success = rs, Message = errMsg
            }));
        }
        public JsonResult UserLogin(string username, string userpwd, string valcode)
        {
            if (string.IsNullOrEmpty(username))
            {
                return(Json(new LoginReturnResult()
                {
                    Success = false, Message = "用户名不能为空", IsShowCode = false
                }));
            }
            if (_Request == null)
            {
                _Request = Request;
            }
            if (_Response == null)
            {
                _Response = Response;
            }
            string errMsg = string.Empty;
            //获取用户信息
            string   tempUserName = GetUserName(username);
            UserInfo userInfo     = UserOperate.GetUserInfo(tempUserName, userpwd, out errMsg);

            if (!string.IsNullOrEmpty(errMsg))
            {
                return(Json(new LoginReturnResult()
                {
                    Success = false, Message = errMsg, IsShowCode = false
                }));
            }
            CacheUserData(userInfo); //缓存cookie
            //执行登录成功后的操作
            CommonOperate.ExecuteUserOperateHandleMethod("AfterLoginSuccess", new object[] { _Request, _Response, username, userpwd, UserInfo.ACCOUNT_EXPIRATION_TIME });

            return(Json(new LoginReturnResult()
            {
                Success = true, Message = string.Empty, Url = string.Empty
            }));
        }
Esempio n. 3
0
        public ActionResult UserLogin(string username, string userpwd, string valcode)
        {
            if (_Request == null)
            {
                _Request = Request;
            }
            if (_Response == null)
            {
                _Response = Response;
            }
            if (_Session == null)
            {
                _Session = Session;
            }
            string errMsg = string.Empty;

            ViewBag.IsShowValidateCode = "false";
            bool isNoCode = _Request["isNoCode"].ObjToBool(); //是否不需要验证码

            if (!isNoCode && _Session[LOGINERROR].ObjToInt() >= 2)
            {
                bool validatecode = false;
                if (_TempData.ContainsKey(SecurityController.VALIDATECODE))
                {
                    string code = _TempData[SecurityController.VALIDATECODE].ToString();
                    validatecode = valcode.ToLower() == code.ToLower();
                }
                if (!validatecode)
                {
                    return(Json(new LoginReturnResult()
                    {
                        Success = false, Message = "验证码错误!", IsShowCode = true
                    }));
                }
            }
            //获取用户信息
            string   tempUserName = GetUserName(username);
            UserInfo userInfo     = UserOperate.GetUserInfo(tempUserName, userpwd, out errMsg);

            if (!string.IsNullOrEmpty(errMsg))
            {
                var isShowCode = false;
                _Session[LOGINERROR] = _Session[LOGINERROR] == null ? 0 : _Session[LOGINERROR].ObjToInt() + 1;
                if (!isNoCode && _Session[LOGINERROR].ObjToInt() >= 2)
                {
                    isShowCode = true;
                }
                return(Json(new LoginReturnResult()
                {
                    Success = false, Message = errMsg, IsShowCode = isShowCode
                }));
            }
            CacheUserData(userInfo); //缓存cookie
            //执行登录成功后的操作
            CommonOperate.ExecuteUserOperateHandleMethod("AfterLoginSuccess", new object[] { _Session, _Request, _Response, username, userpwd, UserInfo.ACCOUNT_EXPIRATION_TIME });

            return(Json(new LoginReturnResult()
            {
                Success = true, Message = string.Empty, Url = HttpUtility.UrlEncode(string.Empty)
            }));
        }