예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //userNo: userNo, oldPwd: oldPwd, newPwd: newPwd
            string userNo = context.Request["userNo"] ?? "UNKNOWN";
            string oldPwd = context.Request["oldPwd"] ?? "UNKNOWN";
            string newPwd = context.Request["newPwd"] ?? "UNKNOWN";

            if (string.IsNullOrEmpty(userNo) && userNo == "UNKNOWN")
            {
                context.Response.Write("用户名不可为空!");
                context.Response.End();
            }
            if (string.IsNullOrEmpty(oldPwd) && oldPwd == "UNKNOWN")
            {
                context.Response.Write("原密码不可为空!");
                context.Response.End();
            }
            if (string.IsNullOrEmpty(newPwd) && newPwd == "UNKNOWN")
            {
                context.Response.Write("新密码不可为空!");
                context.Response.End();
            }
            Ctrl.Bll.SysUserBll sysUserBll = new Ctrl.Bll.SysUserBll();
            if (sysUserBll.ChangePwd(userNo, oldPwd, newPwd))
            {
                context.Response.Write("success");
                context.Response.End();
            }
            else
            {
                context.Response.Write("密码修改失败!");
                context.Response.End();
            }
        }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string userNo = context.Request["userNo"] ?? "UNKNOWN";
            string pwd    = context.Request["password"];

            try
            {
                Ctrl.Bll.SysUserBll sysUserBll = new Ctrl.Bll.SysUserBll();
                bool res = sysUserBll.UserValid(userNo, pwd);
                if (res)
                {
                    if (context.Request.Cookies["MesCookie"] == null)
                    {
                        HttpCookie cookies  = new HttpCookie("MesCookie");
                        string     userName = sysUserBll.GetUserName(userNo);
                        cookies.Value = Common.JsonHelper.SerializeObject(new { userNo = userNo, userName = Common.UnicodeConvert.String2Unicode(userName), loginTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff") });
                        DateTime dtExpires = DateTime.Now + new TimeSpan(0, 20, 0);
                        cookies.Expires = dtExpires;
                        context.Response.AppendCookie(cookies);
                    }
                    else
                    {
                        HttpCookie cookies = context.Request.Cookies["MesCookie"];
                        cookies.Value = Common.JsonHelper.SerializeObject(new { userNo = userNo, userName = sysUserBll.GetUserName(userNo), loginTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff") });
                        DateTime dtExpires = DateTime.Now + new TimeSpan(0, 20, 0);
                        cookies.Expires = dtExpires;
                        context.Response.Cookies.Clear();
                        context.Response.AppendCookie(cookies);
                    }
                }
                context.Response.Write(res.ToString().ToLower());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }