Esempio n. 1
0
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (HttpContext.Current.Request.QueryString.AllKeys.Contains("ConnectionKey"))
            {
                var connectionKey = HttpContext.Current.Request.QueryString["ConnectionKey"];
                Admin.Helpers.CurrentSettings.SetConnectionKeyToCookies(connectionKey);
                InitConnection(connectionKey);
            }
            else if (HttpContext.Current.Request.Cookies.AllKeys.Contains("ConnectionKey"))
            {
                var connectionKey = HttpContext.Current.Request.Cookies["ConnectionKey"];
                if (Admin.DAL.Settings.ConnectionKey != connectionKey.Value)
                {
                    InitConnection(connectionKey.Value);
                }
            }

            if (HttpContext.Current.Request.QueryString.AllKeys.Contains("LangKey"))
            {
                var lang = HttpContext.Current.Request.QueryString["LangKey"];
                if (!string.IsNullOrEmpty(lang))
                {
                    Admin.Helpers.CurrentSettings.SetLangToCookies(lang);
                    InitCulture(lang);
                }
            }
            else if (HttpContext.Current.Request.Cookies.AllKeys.Contains("LangKey"))
            {
                var lang = HttpContext.Current.Request.Cookies["LangKey"];
                if (!string.IsNullOrEmpty(lang.Value) && Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName != lang.Value)
                {
                    InitCulture(lang.Value);
                }
            }
            else
            {
                InitCulture("en");
            }

            string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;

            if (controllerName == "Account")
            {
                return;
            }

            bool isAllow = SecurityCache.CheckPermission("Common", "AccessToAdminPanel");

            if (!isAllow)
            {
                filterContext.HttpContext.Response.Redirect("~/Account/AccessDenied");
            }
        }
Esempio n. 2
0
        public ActionResult Can(string group, string permission)
        {
            var res = SecurityCache.CheckPermission(group, permission);

            return(Content(res.ToString()));
        }