public bool TryGet(RouteRequestLookupInfo routeRequestLookupInfo, out string redirectUrl)
        {
            string resultUrl = null;

            if (_pageByFieldType.TryFindPage(page =>
            {
                var url = _urlService.GetUrl(page, new PageUrlArgs(routeRequestLookupInfo.Channel.SystemId));
                if (url == null)
                {
                    return(false);
                }
                resultUrl = string.Concat(url, url.Contains("?") ? "&" : "?", "RedirectUrl=", HttpUtility.UrlEncode(routeRequestLookupInfo.RawUrl));
                var statusCode = HttpContext.Current?.Response.StatusCode;
                if (Thread.CurrentPrincipal.Identity.IsAuthenticated || statusCode == (int)HttpStatusCode.Unauthorized)
                {
                    resultUrl += $"&code={statusCode}";
                }
                return(true);
            }))
            {
                redirectUrl = resultUrl;
                return(true);
            }

            return(_parentResolver.TryGet(routeRequestLookupInfo, out redirectUrl));
        }
        private Page GetWelcomeEmailPage()
        {
            Page result = null;

            _pageByFieldType.TryFindPage(page =>
            {
                result = page;
                return(true);
            });

            return(result);
        }
        private LinkModel GetLoginPageLink()
        {
            LinkModel loginPage = null;

            _pageByFieldType.TryFindPage(page =>
            {
                if (page == null)
                {
                    return(false);
                }

                loginPage = page.MapTo <LinkModel>();
                loginPage = loginPage != null && loginPage.AccessibleByUser ? loginPage : null;
                return(true);
            }, true);

            return(loginPage);
        }
Exemplo n.º 4
0
        public HeaderViewModel Build()
        {
            var       website   = _requestModelAccessor.RequestModel.WebsiteModel;
            var       myPage    = website.GetValue <PointerPageItem>(AcceleratorWebsiteFieldNameConstants.MyPagesPage)?.MapTo <LinkModel>();
            LinkModel loginPage = null;

            _pageByFieldType.TryFindPage(login =>
            {
                if (login == null)
                {
                    return(false);
                }

                loginPage = CreateLoginLink(login.MapTo <LinkModel>());
                return(loginPage != null);
            }, true);

            var topLinkList = website.GetValue <IList <PointerItem> >(AcceleratorWebsiteFieldNameConstants.AdditionalHeaderLinks)?.OfType <PointerPageItem>().ToList().Select(x => x.MapTo <LinkModel>()).Where(x => x != null).ToList();

            myPage = myPage?.AccessibleByUser == true ? myPage : null;

            var startPage    = _pageService.GetChildPages(Guid.Empty, website.SystemId).FirstOrDefault();
            var startPageUrl = _urlService.GetUrl(startPage, new PageUrlArgs(_requestModelAccessor.RequestModel.ChannelModel.SystemId));

            return(new HeaderViewModel
            {
                Logo = website.Fields.GetValue <Guid?>(AcceleratorWebsiteFieldNameConstants.LogotypeMain)?.MapTo <ImageModel>(),
                TopLinkList = topLinkList ?? new List <LinkModel>(),
                LoginPage = loginPage ?? new LinkModel(),
                MyPage = myPage ?? new LinkModel(),
                StartPageUrl = string.IsNullOrWhiteSpace(startPageUrl) ? "/" : startPageUrl,
                IsLoggedIn = !Thread.CurrentPrincipal.Identity.IsAuthenticated,
                IsBigHeader = website.Fields.GetValue <string>(AcceleratorWebsiteFieldNameConstants.HeaderLayout) == HeaderLayoutConstants.TwoRows,
                HeaderName = website.Fields.GetValue <string>(AcceleratorWebsiteFieldNameConstants.HeaderLayout),
                QuickSearch = new QuickSearchViewModel
                {
                    IsBigHeader = website.Fields.GetValue <string>(AcceleratorWebsiteFieldNameConstants.HeaderLayout) == HeaderLayoutConstants.TwoRows,
                    SearchTerm = _requestModelAccessor.RequestModel.SearchQuery.Text
                }
            });
        }
Exemplo n.º 5
0
        private List <PageModel> GetMegaMenuPages()
        {
            var megaMenuPages = new List <PageModel>();

            _pageByFieldType.TryFindPage(page =>
            {
                if (page != null)
                {
                    var pageModel = page.MapTo <PageModel>();
                    // pageModel can be null if current user does not have access to it
                    // or if the page is not published on the current channel
                    if (pageModel != null)
                    {
                        megaMenuPages.Add(pageModel);
                    }
                }

                return(false);
            });
            return(megaMenuPages.OrderBy(p => p.Page.SortIndex).ToList());
        }
        public bool TryGet(RouteRequestLookupInfo routeRequestLookupInfo, out string redirectUrl)
        {
            string resultUrl = null;

            if (_pageByFieldType.TryFindPage(page =>
            {
                var url = _urlService.GetUrl(page, new PageUrlArgs(routeRequestLookupInfo.Channel.SystemId));
                if (url == null)
                {
                    return(false);
                }
                resultUrl = string.Concat(url, url.Contains("?") ? "&" : "?", "RedirectUrl=", HttpUtility.UrlEncode(routeRequestLookupInfo.RawUrl));
                return(true);
            }))
            {
                redirectUrl = resultUrl;
                return(true);
            }

            return(_parentResolver.TryGet(routeRequestLookupInfo, out redirectUrl));
        }
        public bool TryGet(RouteRequestLookupInfo routeRequestLookupInfo, out RouteRequestInfo routeRequestInfo)
        {
            var result = new RouteRequestInfo();

            if (_pageByFieldType.TryFindPage(page =>
            {
                var url = _urlService.GetUrl(page, new PageUrlArgs(routeRequestLookupInfo.Channel.SystemId));
                if (url == null)
                {
                    return(false);
                }

                result.PageSystemId = page.SystemId;
                result.DataPath = url;
                return(true);
            }))
            {
                routeRequestInfo = result;
                return(true);
            }

            return(_parentResolver.TryGet(routeRequestLookupInfo, out routeRequestInfo));
        }
Exemplo n.º 8
0
            public LinkModel Resolve(PageModel source, MyPagesViewModel destination, LinkModel destMember, ResolutionContext context)
            {
                LinkModel loginPage = null;
                var       found     = _pageByFieldType.TryFindPage(login =>
                {
                    loginPage = login?.MapTo <LinkModel>();
                    if (loginPage == null)
                    {
                        return(false);
                    }
                    return(true);
                });

                if (!found)
                {
                    return(null);
                }
                if (loginPage.Href != null)
                {
                    loginPage.Href += ".Logout";
                }
                return(loginPage);
            }