Пример #1
0
 protected override void OnAuthorization(AuthorizationContext filterContext)
 {
     base.OnAuthorization(filterContext);
     if (filterContext.IsChildAction)
     {
         return;
     }
     //if (base.CurrentUser == null || base.CurrentUser.Disabled)
     if (base.CurrentUser == null)
     {
         if (WebHelper.IsAjax())
         {
             BaseController.Result result = new BaseController.Result()
             {
                 msg     = "登录超时,请重新登录!",
                 success = false
             };
             filterContext.Result = base.Json(result);
             return;
         }
         HttpRequestBase       request = filterContext.HttpContext.Request;
         string                str     = HttpUtility.HtmlEncode(request.RawUrl.ToString());
         RedirectToRouteResult action  = base.RedirectToAction("", "Login", new { area = "Web", returnUrl = str });
         if (base.CurrentSellerManager != null && !base.IsMobileTerminal)
         {
             action = base.RedirectToAction("index", "Home", new { area = "SellerAdmin" });
         }
         if (!base.IsMobileTerminal)
         {
             filterContext.Result = action;
         }
     }
 }
Пример #2
0
        private bool CheckLoginStatus(AuthorizationContext filterContext)
        {
            bool flag = true;

            if (base.CurrentSellerManager == null && base.CurrentUser == null)
            {
                if (!WebHelper.IsAjax())
                {
                    HttpRequestBase       request = filterContext.HttpContext.Request;
                    string                str     = HttpUtility.HtmlEncode(request.RawUrl.ToString());
                    RedirectToRouteResult action  = base.RedirectToAction("", "Login", new { area = "web", returnUrl = str });
                    filterContext.Result = action;
                    flag = false;
                }
                else
                {
                    BaseController.Result result = new BaseController.Result()
                    {
                        msg     = "登录超时,请重新登录!",
                        success = false
                    };
                    filterContext.Result = base.Json(result);
                    flag = false;
                }
            }
            else if (base.CurrentUser != null && base.CurrentSellerManager == null)
            {
                RedirectToRouteResult redirectToRouteResult = base.RedirectToAction("EditProfile1", "ShopProfile", new { area = "SellerAdmin" });
                filterContext.Result = redirectToRouteResult;
                flag = false;
            }
            return(flag);
        }
Пример #3
0
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            base.InitVisitorTerminal();
            string item = ConfigurationManager.AppSettings["IsInstalled"];

            if (item != null && !bool.Parse(item))
            {
                return;
            }
            if (filterContext.IsChildAction)
            {
                return;
            }
            if (CurrentManager == null)
            {
                if (!WebHelper.IsAjax())
                {
                    RedirectToRouteResult action = base.RedirectToAction("", "Login", new { area = "admin" });
                    filterContext.Result = action;
                    return;
                }
                BaseController.Result result = new BaseController.Result()
                {
                    msg     = "登录超时,请重新登录!",
                    success = false
                };
                filterContext.Result = base.Json(result);
                return;
            }
            if (filterContext.ActionDescriptor.GetCustomAttributes(typeof(UnAuthorize), false).Length == 1)
            {
                return;
            }
            string lower = filterContext.RouteData.Values["controller"].ToString().ToLower();
            string str   = filterContext.RouteData.Values["action"].ToString().ToLower();

            //if (CurrentManager.AdminPrivileges == null || CurrentManager.AdminPrivileges.Count == 0 || !AdminPermission.CheckPermissions(CurrentManager.AdminPrivileges, lower, str))
            //修改 5月9日
            if (CurrentManager.AdminPrivileges == null || CurrentManager.AdminPrivileges.Count == 0)
            {
                if (WebHelper.IsAjax())
                {
                    BaseController.Result result1 = new BaseController.Result()
                    {
                        msg     = "你没有访问的权限!",
                        success = false
                    };
                    filterContext.Result = base.Json(result1);
                    return;
                }
                ViewResult viewResult = new ViewResult()
                {
                    ViewName = "NoAccess"
                };
                viewResult.TempData.Add("Message", "你没有权限访问此页面");
                viewResult.TempData.Add("Title", "你没有权限访问此页面!");
                filterContext.Result = viewResult;
            }
        }
 private bool ProcessInvalidUser_Ajax(ActionExecutingContext filterContext)
 {
     BaseController.Result result = new BaseController.Result()
     {
         msg     = "登录超时,请重新登录!",
         success = false
     };
     filterContext.Result = base.Json(result);
     return(true);
 }
Пример #5
0
        private bool CheckAuthorization(AuthorizationContext filterContext)
        {
            bool flag = true;

            if (filterContext.ActionDescriptor.GetCustomAttributes(typeof(UnAuthorize), false).Length == 1)
            {
                return(true);
            }
            string str  = filterContext.RouteData.Values["controller"].ToString();
            string str1 = filterContext.RouteData.Values["action"].ToString();

            if (base.CurrentSellerManager.SellerPrivileges == null || base.CurrentSellerManager.SellerPrivileges.Count == 0 || !SellerPermission.CheckPermissions(base.CurrentSellerManager.SellerPrivileges, str, str1))
            {
                if (!WebHelper.IsAjax())
                {
                    ViewResult viewResult = new ViewResult()
                    {
                        ViewName = "NoAccess"
                    };
                    viewResult.TempData.Add("Message", "你没有权限访问此页面");
                    viewResult.TempData.Add("Title", "你没有权限访问此页面!");
                    filterContext.Result = viewResult;
                    flag = false;
                }
                else
                {
                    BaseController.Result result = new BaseController.Result()
                    {
                        msg     = "你没有访问的权限!",
                        success = false
                    };
                    filterContext.Result = base.Json(result);
                    flag = false;
                }
            }
            return(flag);
        }
Пример #6
0
        protected override void OnException(ExceptionContext filterContext)
        {
            Exception exception = GerInnerException(filterContext.Exception);
            string    message   = exception.Message;

            base.OnException(filterContext);
            if (!(exception is HimallException))
            {
                string str  = filterContext.RouteData.Values["controller"].ToString();
                string str1 = filterContext.RouteData.Values["action"].ToString();
                object item = filterContext.RouteData.DataTokens["area"];
                string str2 = string.Format("页面未捕获的异常:Area:{0},Controller:{1},Action:{2}", item, str, str1);
                Log.Error(str2, exception);
                message = "系统内部异常";
            }
            if (!WebHelper.IsAjax())
            {
                ViewResult viewResult = new ViewResult()
                {
                    ViewName = "Error"
                };
                viewResult.TempData.Add("Message", filterContext.Exception.ToString());
                viewResult.TempData.Add("Title", message);
                filterContext.Result = viewResult;
                filterContext.HttpContext.Response.StatusCode = 200;
                filterContext.ExceptionHandled = false;
                DisposeService(filterContext);
            }
            else
            {
                BaseController.Result result = new BaseController.Result()
                {
                    success = false,
                    msg     = message,
                    status  = -9999
                };
                filterContext.Result = base.Json(result);
                filterContext.HttpContext.Response.StatusCode = 200;
                filterContext.ExceptionHandled = true;
                DisposeService(filterContext);
            }
            if (exception is HttpRequestValidationException)
            {
                if (!WebHelper.IsAjax())
                {
                    ContentResult contentResult = new ContentResult()
                    {
                        Content = "<script src='/Scripts/jquery-1.11.1.min.js'></script>"
                    };
                    ContentResult contentResult1 = contentResult;
                    contentResult1.Content = string.Concat(contentResult1.Content, "<script src='/Scripts/jquery.artDialog.js'></script>");
                    ContentResult contentResult2 = contentResult;
                    contentResult2.Content = string.Concat(contentResult2.Content, "<script src='/Scripts/artDialog.iframeTools.js'></script>");
                    ContentResult contentResult3 = contentResult;
                    contentResult3.Content = string.Concat(contentResult3.Content, "<link href='/Content/artdialog.css' rel='stylesheet' />");
                    ContentResult contentResult4 = contentResult;
                    contentResult4.Content = string.Concat(contentResult4.Content, "<link href='/Content/bootstrap.min.css' rel='stylesheet' />");
                    ContentResult contentResult5 = contentResult;
                    contentResult5.Content = string.Concat(contentResult5.Content, "<script>$(function(){$.dialog.errorTips('您提交了非法字符!',function(){window.history.back(-1)},2);});</script>");
                    filterContext.Result   = contentResult;
                }
                else
                {
                    BaseController.Result result1 = new BaseController.Result()
                    {
                        msg = "您提交了非法字符!"
                    };
                    filterContext.Result = base.Json(result1);
                }
                filterContext.HttpContext.Response.StatusCode = 200;
                filterContext.ExceptionHandled = true;
                DisposeService(filterContext);
            }
        }