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>(); }
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))); }
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); }
public bool IsUserRestrictedByEntitlement(IGeneral_Content_Page page) { bool isRestricted = ((IGeneral_Content_Page)page).Restrict_Access.Equals(ItemReferences.FreeWithEntitlement); return(isRestricted && !IsUserEntitled(page)); }
public bool IsUserRestrictedByRegistration(IGeneral_Content_Page page) { bool isRestricted = page.Restrict_Access.Equals(ItemReferences.FreeWithRegistration); return(isRestricted && !AuthenticatedUserContext.IsAuthenticated); }
public bool IsPageRestrictionSet(IGeneral_Content_Page page) { return(page.Restrict_Access.Equals(ItemReferences.FreeWithRegistration) || page.Restrict_Access.Equals(ItemReferences.FreeWithEntitlement)); }