Esempio n. 1
0
        public AdminInfo()
        {
            HttpCookie Cookie = HttpContext.Current.Request.Cookies[AuthorIIdentity.C_SESSION_NAME];

            if (Cookie == null || string.IsNullOrEmpty(Cookie.Value))
            {
                return;
            }
            string str = HttpUtility.HtmlDecode(Cookie.Value);

            string ui = AdminCookieEnCode.Decode(str, HttpContext.Current.Request.UserAgent);

            if (string.IsNullOrEmpty(ui))
            {
                return;
            }
            string[] ds = ui.Split('|');
            if (ds.Length != 3)
            {
                return;
            }
            int.TryParse(ds[0], out AdminId);
            if (AdminId == 0)
            {
                return;
            }

            AdminName   = ds[1];
            RightString = ds[2];
            return;
        }
Esempio n. 2
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest Request = context.Request;


            string userName = Request["userName"];
            string password = Request["password"];
            string pType    = Request["pType"];

            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                Static.ClientRedirect("用户名或密码为能为空!");
                return;
            }

            string userInfo;

            using (this.dBase = CreateDBase())
            {
                userInfo = DoLogin(userName, password, pType);
            }
            if (userInfo == null)
            {
                Static.ClientRedirect("用户名或密码错误!");
                return;
            }
            if (!Regex.IsMatch(userInfo, "^.+?\\|.+?\\|[^\\|]{0,}$"))
            {
                Static.ClientRedirect(userInfo);
                return;
            }
            if (Mode == AuthorMode.TickForm)
            {
                WriteTick(userInfo.Split(new char[] { '|' }));
            }
            else
            {
                HttpCookie ec = new HttpCookie(AuthorIIdentity.C_SESSION_NAME);
                if (!Request.IsLocal)
                {
                    ec.Domain = Domain;
                }

                ec.HttpOnly = true;
                ec.Value    = AdminCookieEnCode.Encode(userInfo, Request.UserAgent);
                context.Response.Cookies.Add(ec);
            }
            string ret = Request["returnUrl"];

            if (!string.IsNullOrEmpty(ret))
            {
                context.Response.Redirect(ret);
            }
            else
            {
                context.Response.Redirect("~/");
            }
        }