Esempio 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;
         }
     }
 }
Esempio 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 = "用户名或密码不能为空";
                }
            }
        }
Esempio n. 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         url = Request["returnurl"];
     }
     if (IsPostBack)
     {
         string txtName     = Request["txtName"];
         string txtRealName = Request["txtRealName"];
         string txtPwd      = Request["txtRealName"];
         url = Request["returnurl"];
         string  txtCode = Request["txtCode"];
         m.Users users   = new m.Users();
         b.Users bll     = new b.Users();
         int     count   = 0;
         if (bll.GetCountByName(txtName) != 0)
         {
             count++;
         }
         if (txtCode != (string)Session["validate"])
         {
             Session["validate"] = null;
             count++;
         }
         if (String.IsNullOrEmpty(txtPwd))
         {
             count++;
         }
         if (count == 0)
         {
             users.LoginId     = txtName;
             users.Name        = txtRealName;
             users.LoginPwd    = Md5Util.GetMd5(txtPwd);
             users.UserStateId = 1;
             bll.Add(users);
             Session["user"] = users;
             if (url != null)
             {
                 Response.Redirect(url);
             }
             Response.Redirect("default.aspx");
         }
     }
 }
Esempio n. 4
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));
            }
        }
Esempio n. 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            b.Users bll     = new b.Users();
            string  address = context.Request["address"];

            m.Users user = bll.GetUserByMail(address);
            if (user != null)
            {
                string password = Guid.NewGuid().ToString().Substring(0, 8);
                SendMail(address, user.LoginId, "bookshop3密码修改", "您的新密码是" + password);
                user.LoginPwd = Md5Util.GetMd5(password);
                bll.Update(user);
                context.Response.Write("yes");
            }
            else
            {
                context.Response.Write("no");
            }
        }
Esempio n. 6
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());
         }
     }
 }