Пример #1
0
 public IObjectCache DataCache(String cemexId, int idPaisapp)
 {
     CmpAuth adp = new CmpAuth();
     return new ObjectCache(_cmpCache.GetAuth(cemexId), _cmpCache.GetPages(idPaisapp, adp.GetAuth(cemexId).ElementAt(0).RolId));
 }
Пример #2
0
        /// <summary>
        /// Administra la autorización por Request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AuthorizeRequest(object sender, EventArgs e)
        {
            var lt = new List<String>() { "/Account/", "/Videos/", "/Images/", "/Scripts/","/Content/" ,"/Style/", "/Documentos/","/Error/","/GestorHC/", "/ErrorPages/", ".axd", ".ashx",".asmx",".pdf",".xls" };
            if (((IObjectCache)System.Web.HttpContext.Current.Cache.Get("Lpg")) == null)
            {
                var au = HttpContext.Current.User == null? null : new CmpAuth().GetAuth(HttpContext.Current.User.Identity.Name.ToString());
                if (HttpContext.Current.User != null?au.Count() > 0:false)
                {
                    var pg = new CmpAuth().GetPages(au.ElementAt(0).PaisAppId, au.ElementAt(0).RolId);
                    UsrCache.AddPagesToCache("Lpg", new ObjectCache(au, pg), HttpContext.Current);
                }
                else
                {
                    var pg = new CmpAuth().GetPages(0, 100);
                    UsrCache.AddPagesToCache("Lpg", new ObjectCache(null, pg), HttpContext.Current);
                }

                //HttpContext.Current.Server.Transfer("~/Account/AuthE.aspx");
                // HttpContext.Current.Server.Transfer("~/Account/Login.aspx");
            }
            if (lt.Any(r => HttpContext.Current.Request.Path.ToLower().Contains(r.ToLower())))
            {
                return;
            }
            if (HttpContext.Current.User != null)
            {
                //Si el usuario esta Autenticado
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    if (HttpContext.Current.User is FPrincipal)
                    {
                        FPrincipal principal = (FPrincipal)HttpContext.Current.User;
                        if (!principal.IsPageEnabled(HttpContext.Current.Request.Path))
                        {
                            HttpContext.Current.Server.Transfer("~/Account/AuthE.aspx");
                        }
                    }
                }
            }
        }
Пример #3
0
 public ServAuth()
 {
     cmpAuth= new CmpAuth();
 }