Esempio n. 1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            NHibernateHelper.BindSession();

            try
            {
                #region 验证用户是否登陆过
                if (Request.Cookies["LoginCookie"] != null)
                {
                    if (Request.Cookies["LoginCookie"]["membername"] != null &&
                        Request.Cookies["LoginCookie"]["memberpassword"] != null &&
                        Request.Cookies["LoginCookie"]["keeping"] != null)
                    {
                        string memberName = Request.Cookies["LoginCookie"]["membername"];
                        memberName = DESEncrypt.Decrypt(memberName, "membername");
                        memberName = HttpUtility.UrlDecode(memberName);
                        string memberPassword = Request.Cookies["LoginCookie"]["memberpassword"];
                        memberPassword = DESEncrypt.Decrypt(memberPassword, "memberpassword");
                        memberPassword = HttpUtility.UrlDecode(memberPassword);
                        string keeping = Request.Cookies["LoginCookie"]["keeping"];
                        if (memberName != "" && memberPassword != "" && keeping != "")
                        {
                            //MemberLogin(memberName, memberPassword, keeping == "1");

                            bool result = UserLogin(memberName, memberPassword, keeping == "1");
                            #region 用户登录
                            //Model.D_User_Model model = new DAL.D_User_DAL().GetUserByUserLoginName(memberName);
                            //if (model != null)
                            //{
                            //    if (new DAL.D_User_DAL().PassWordMD5(memberPassword).Equals(model.PassWord.ToLower()))
                            //    {
                            //        UserView = model;
                            //        ViewBag.UserView = model;

                            //        if (Request.Cookies["LoginCookie"] == null)
                            //        {
                            //            SetLoginCookies(memberName, memberPassword, keeping == "1");
                            //        }

                            //    }
                            //}
                            #endregion
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                HttpContextWrite(filterContext, ex.Message);
            }

            HttpContext.Items["User"] = UserView;
        }