Inheritance: ISiteSettingsProvider
        /// <summary>
        /// Handles access denied for forms authentication scenarios by redirecting to the logon form.
        ///
        /// </summary>
        /// <param name="filter"></param>
        private static void FormLogonAccessDenied(AuthorizationContext filter)
        {
            IContentRepository contentRepository = ServiceLocator.Current.GetInstance <IContentRepository>();
            UrlResolver        urlResolver       = ServiceLocator.Current.GetInstance <UrlResolver>();

            string str      = HttpContext.Current.Request.Url.PathAndQuery;
            var    loginUrl =
                urlResolver.GetUrl(SiteConfiguration.Current().Settings.LoginPage);

            filter.Result = new RedirectResult(loginUrl + "?ReturnUrl=" + HttpContext.Current.Server.UrlEncode(str));
        }
Example #2
0
        public static SiteConfiguration Current()
        {
            var contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>();

            // This can actually be 0 if we have a problem with our language settings
            if (ContentReference.StartPage != null && ContentReference.StartPage.ID > 0)
            {
                var startPage            = contentLoader.Get <HomePage>(ContentReference.StartPage);
                SiteConfiguration config = new SiteConfiguration
                {
                    Settings = startPage.Settings
                };

                return(config);
            }
            return(new SiteConfiguration());
        }
        /// <summary>
        /// Called before an action result executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            SettingsBlock settings = SiteConfiguration.Current().Settings;

            // This can actually be null if we have a problem with our language settings
            if (settings != null)
            {
                var chrome = new Chrome();
                chrome.TopLeftMenu      = settings.TopLeftMenu;
                chrome.TopRightMenu     = settings.TopRightMenu;
                chrome.FooterMenu       = GetFooterMenuContent(settings);
                chrome.SocialMediaIcons = settings.SocialMediaIcons;
                chrome.FooterButtons    = settings.FooterButtons;
                chrome.LoginPage        = settings.LoginPage;
                chrome.AccountPage      = settings.AccountPage;

                chrome.CheckoutPage = settings.CheckoutPage;
                chrome.SearchPage   = settings.SearchPage;
                if (settings.LogoImage != null)
                {
                    chrome.LogoImageUrl = _urlResolver.GetUrl(settings.LogoImage);
                }
                else
                {
                    chrome.LogoImageUrl = new Url("/Content/Images/commerce-shop-logo.png");
                }

                // Set up languages for Chrome
                var contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>();
                var startPage     = contentLoader.Get <HomePage>(ContentReference.StartPage);
                chrome.Language  = startPage.LanguageBranch;
                chrome.Languages = GetLanguageInfo(startPage);

                filterContext.Controller.ViewBag.Chrome = chrome;
            }
        }