Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.Cookies["username"] != null)
     {
         b.Users userBll = new b.Users();
         m.Users user    = userBll.GetUserByName(Request.Cookies["username"].Value);
         if (user.LoginPwd == Request.Cookies["password"].Value)
         {
             Session["user"] = user;
         }
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            url = Request["returnurl"];

            Response.ContentType = "text/html;charset=utf-8";
            if (Request.HttpMethod.ToLower() == "post")
            {
                string username = Request["username"];
                string password = Request["password"];
                if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    b.Users usersBll = new b.Users();
                    m.Users user     = usersBll.GetUserByName(username);
                    if (user != null)
                    {
                        if (c.Md5Util.GetMd5(password) == user.LoginPwd)
                        {
                            Session["user"] = user;
                            if (!string.IsNullOrEmpty(Request["autoLogin"]))
                            {
                                HttpCookie cName = new HttpCookie("username");
                                HttpCookie cPwd  = new HttpCookie("password");
                                cName.Value   = user.LoginId;
                                cPwd.Value    = user.LoginPwd;
                                cName.Expires = DateTime.Now.AddDays(7);
                                cPwd.Expires  = DateTime.Now.AddDays(7);
                                Response.SetCookie(cName);
                                Response.SetCookie(cPwd);
                            }
                            if (url != null)
                            {
                                Response.Redirect(url);
                            }
                        }
                    }
                    else
                    {
                        Msg = "用户名或密码错误";
                    }
                }
                else
                {
                    Msg = "用户名或密码不能为空";
                }
            }
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string msg = context.Request["msg"];
            int    bookid;

            bool result = int.TryParse(context.Request["bookid"], out bookid);

            if (msg == null)
            {
                if (!result)
                {
                    System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                    m.Users user = context.Session["user"] as m.Users;
                    if (context.Session["user"] == null)
                    {
                        if (context.Request["username"] != null)
                        {
                            b.Users bll      = new b.Users();
                            m.Users baseUser = bll.GetUserByName(context.Request["username"]);
                            if (baseUser.LoginPwd == context.Request["password"])
                            {
                                context.Response.Write(javaScriptSerializer.Serialize(baseUser));
                                context.Response.End();
                            }
                        }
                        context.Response.Write(javaScriptSerializer.Serialize(new { Msg = "no" }));
                        context.Response.End();
                    }
                    else
                    {
                        context.Response.Write(javaScriptSerializer.Serialize(user));
                    }
                }
                else
                {
                    context.Response.Write(LoadCommnet(bookid));
                }
            }
            else
            {
                context.Response.Write(AddComment(bookid, msg));
            }
        }
Ejemplo n.º 4
0
 protected void Page_Init(object sender, EventArgs e)
 {
     if (Session["user"] == null)
     {
         if (Request.Cookies["username"] != null)
         {
             b.Users userBll = new b.Users();
             m.Users user    = userBll.GetUserByName(Request.Cookies["username"].Value);
             if (user.LoginPwd == Request.Cookies["password"].Value)
             {
                 Session["user"] = user;
             }
             else
             {
                 Response.Redirect("/aspx/Login.aspx?returnurl=" + Request.Url.ToString());
             }
         }
         else
         {
             Response.Redirect("/aspx/Login.aspx?returnurl=" + Request.Url.ToString());
         }
     }
 }