public void ProcessRequest(HttpContext ctx) { //userInfo = context.Session["dn_session_user_info"] as UserInfoDto; //if (userInfo == null) // 用户未登录 //{ // context.Response.Write(new Tools.Serialize().SerializeJson("{\"status\": '1', \"msg\": \"用户未登录!\"}")); // context.Response.End(); // return; //} //userPermit = context.Session["dn_session_user_permits"] as List<AuthPermitDto>; string token = EMT.Tools.Common.GetCookie("Token", "DoneNOW"); if (string.IsNullOrEmpty(token)) { ctx.Response.Write(new Tools.Serialize().SerializeJson(new string[] { "status=1", "用户未登录" })); ctx.Response.End(); return; } userInfo = AuthBLL.GetLoginUserInfo(token); if (userInfo == null) { ctx.Response.Write(new Tools.Serialize().SerializeJson(new string[] { "status=1", "用户未登录" })); ctx.Response.End(); return; } userPermit = AuthBLL.GetLoginUserPermit(token); // 判断用户是否可以访问当前url if (!CheckUserAccess(ctx.Request.RawUrl)) { ctx.Response.Write(new Tools.Serialize().SerializeJson(new string[] { "status=2", "没有权限操作" })); ctx.Response.End(); return; } request = ctx.Request; response = ctx.Response; AjaxProcess(ctx); }
private bool IsUserLogin() { /* * //sys_user user = new sys_user { id = 1, email = "*****@*****.**", name="刘海", mobile_phone = "18217750743" }; * //sys_user user = new sys_user { id = 2, email = "*****@*****.**", name = "朱飞", mobile_phone = "12" }; * //Session["dn_session_user_info"] = user; * if (Session["dn_session_user_info"] != null) * { * userInfo = Session["dn_session_user_info"] as UserInfoDto; * userPermit = Session["dn_session_user_permits"] as List<AuthPermitDto>; * return true; * } * else * { * //检查Cookies * string username = EMT.Tools.Common.GetCookie("UserName", "DoneNOW"); * string userpwd = EMT.Tools.Common.GetCookie("UserPwd", "DoneNOW"); * if (username != "" && userpwd != "") * { * // TODO: 验证用户名密码 * return false; * } * } */ string token = EMT.Tools.Common.GetCookie("Token", "DoneNOW"); if (string.IsNullOrEmpty(token)) { return(false); } userInfo = AuthBLL.GetLoginUserInfo(token); if (userInfo == null) { return(false); } userPermit = AuthBLL.GetLoginUserPermit(token); return(true); }