public void SetUp()
 {
     AuthUserContext          = Substitute.For <IAuthenticatedUserContext>();
     ItemReferences           = Substitute.For <IItemReferences>();
     EntitlementsContext      = Substitute.For <IUserEntitlementsContext>();
     SiteRoots                = Substitute.For <ISiteRootsContext>();
     AccountManagementService = new AccountManagementService(AuthUserContext, ItemReferences, EntitlementsContext, SiteRoots);
     GeneralPage              = Substitute.For <IGeneral_Content_Page>();
 }
Пример #2
0
        public bool IsUserEntitled(IGeneral_Content_Page page)
        {
            var siteRoot = SiteRootsContext.SiteRoots.FirstOrDefault(sr => page._Path.StartsWith(sr._Path));

            if (siteRoot == null)
            {
                return(false);
            }

            return(UserEntitlementsContext.Entitlements.Any(e => string.Equals(e.ProductCode, siteRoot.Publication_Code, StringComparison.CurrentCultureIgnoreCase)));
        }
Пример #3
0
        public bool IsUserRestricted(I___BasePage page)
        {
            bool isGeneralContentPage = page is IGeneral_Content_Page;

            if (!isGeneralContentPage)
            {
                return(false);
            }

            IGeneral_Content_Page gPage = (IGeneral_Content_Page)page;

            return((IsUserRestrictedByRegistration(gPage) || IsUserRestrictedByEntitlement(gPage))
                ? true
                : false);
        }
Пример #4
0
        public bool IsUserRestrictedByEntitlement(IGeneral_Content_Page page)
        {
            bool isRestricted = ((IGeneral_Content_Page)page).Restrict_Access.Equals(ItemReferences.FreeWithEntitlement);

            return(isRestricted && !IsUserEntitled(page));
        }
Пример #5
0
        public bool IsUserRestrictedByRegistration(IGeneral_Content_Page page)
        {
            bool isRestricted = page.Restrict_Access.Equals(ItemReferences.FreeWithRegistration);

            return(isRestricted && !AuthenticatedUserContext.IsAuthenticated);
        }
Пример #6
0
 public bool IsPageRestrictionSet(IGeneral_Content_Page page)
 {
     return(page.Restrict_Access.Equals(ItemReferences.FreeWithRegistration) || page.Restrict_Access.Equals(ItemReferences.FreeWithEntitlement));
 }