Carrotware.CMS.Core.SecurityData.GetIsAdminFromCache C# (CSharp) Метод

GetIsAdminFromCache() публичный статический Метод

public static GetIsAdminFromCache ( ) : bool
Результат bool
        public static bool GetIsAdminFromCache()
        {
            bool keyVal = false;

            if (SiteData.IsWebView && IsAuthenticated) {
                string key = String.Format("{0}_{1}", keyIsAdmin, SecurityData.CurrentUserIdentityName);
                if (HttpContext.Current.Cache[key] != null) {
                    keyVal = Convert.ToBoolean(HttpContext.Current.Cache[key]);
                } else {
                    keyVal = IsUserInRole(SecurityData.CMSGroup_Admins);
                    HttpContext.Current.Cache.Insert(key, keyVal.ToString(), null, DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration);
                }
            }

            return keyVal;
        }

Usage Example

Пример #1
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (!SecurityData.IsAuthenticated)
            {
                return(false);
            }

            if (SecurityData.GetIsAdminFromCache())
            {
                return(true);
            }

            return(false);
        }