예제 #1
0
        /// <summary>
        /// 记住用户
        /// </summary>
        /// <returns></returns>
        public ActionResult LoginByRberUser(UserLogin model, string LoginCode)
        {
            string userPwd = DataEncrypt.MD5Encrypt(model.LoginPwd.Trim());

            model.LoginPwd = userPwd;
            //判断验证码是否正确
            if (LoginCode.ToLower() == Session["code"].ToString().ToLower())
            {
                //判断用户是否存在
                if (UserManage.CheckUser(model))
                {
                    if (Request.Cookies.AllKeys.Contains("LoginName"))
                    {
                        var cookietest = Request.Cookies["LoginName"];
                        cookietest.Expires = DateTime.Now.AddDays(-3);
                        Response.Cookies.Add(cookietest);
                    }
                    HttpCookie cookie = new HttpCookie("LoginName", model.LoginName);
                    cookie.Expires = DateTime.Now.AddDays(3);
                    Request.Cookies.Add(cookie);
                    //给用户设置票证
                    FormsAuthentication.SetAuthCookie(model.LoginName.ToString(), false);
                    return(Json(new { success = 1 }));
                }
                else
                {
                    return(Json(new { success = 2 }));
                }
            }
            else
            {
                return(Json(new { success = 3 }));
            }
        }
예제 #2
0
        public ActionResult Login(UserLogin model, string LoginCode)
        {
            string userPwd = DataEncrypt.MD5Encrypt(model.LoginPwd.Trim());

            model.LoginPwd = userPwd;
            //判断验证码是否正确
            if (LoginCode.ToLower() == Session["code"].ToString().ToLower())
            {
                //判断用户是否存在
                if (UserManage.CheckUser(model))
                {
                    //给用户设置票证
                    FormsAuthentication.SetAuthCookie(model.LoginName.ToString(), false);
                    return(Json(new { success = 1 }));
                }
                else
                {
                    return(Json(new { success = 2 }));
                }
            }
            else
            {
                return(Json(new { success = 3 }));
            }
        }