// Note! This broke with CMS 8, but since we're not using the languageselector // from code, we just ignore it //public virtual T Get<T>(ContentReference contentLink) where T : IContentData //{ // // CMS 8 // // LoaderOptions options = new LoaderOptions(); // // options.Add(new LanguageLoaderOption() {FallbackBehaviour = LanguageBehaviour.Fallback}); // return this.Get<T>(contentLink, (LanguageSelector)LanguageSelector.AutoDetect(true)); //} public virtual T Get <T>(ContentReference contentLink) where T : IContentData { T obj = Locate.ContentRepository().Get <T>(contentLink); if ((object)obj == null) { return(default(T)); } AccessLevel access = contentLink.CompareToIgnoreWorkID(this.CurrentContentLink) ? AccessLevel.Read : AccessLevel.Read; ISecurable securable = (object)obj as ISecurable; if (securable != null && !securable.GetSecurityDescriptor().HasAccess(PrincipalInfo.CurrentPrincipal, access)) { if (PrincipalInfo.CurrentPrincipal.Identity.IsAuthenticated) { throw new AccessDeniedException(); } IAccessDeniedHandler handler = ServiceLocator.Current.GetInstance <IAccessDeniedHandler>(); handler.AccessDenied(new HttpContextWrapper(Context)); // Man - we really need to get rid of web forms soon! } return(obj); }
public LoginChecker(StudiBudiContext context, IHttpContextAccessor httpContextAccessor, IAccessDeniedHandler accessDeniedHandler) { _context = context; _httpContextAccessor = httpContextAccessor; _accessDeniedHandler = accessDeniedHandler; }