Exemplo n.º 1
0
        public String DoLoginAjax(E_User model)
        {
            E_User eUser  = dal.GetInfoByName(model);
            String result = "";

            if (eUser != null)
            {
                if (eUser.password == model.password)
                {
                    Utils.AddCookies("username", model.username);
                    Utils.AddCookies("password", model.password);
                    Session["user"] = eUser;
                    return("True");
                }
                else
                {
                    result = "密码错误";
                }
            }
            else
            {
                result = "账号不存在";
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 验证权限(action执行前会先执行这里)
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.HttpContext.Session["user"] == null)
            {
                E_User model = new E_User();
                model.username = Utils.GetCookies("username");
                model.password = Utils.GetCookies("password");

                E_User eUser = dal.GetInfoByName(model);
                if (eUser == null)
                {
                    filterContext.Result = new RedirectResult("/Login/Login/");
                    return;
                }
                if (eUser.password != model.password)
                {
                    filterContext.Result = new RedirectResult("/Login/Login/");
                    return;
                }
                filterContext.HttpContext.Session["user"] = eUser;
            }
        }