Beispiel #1
0
        /// <summary>
        /// Outputs a script tag containing the bare minimum (non secure) server vars for use with the angular app
        /// </summary>
        /// <param name="html"></param>
        /// <param name="uri"></param>
        /// <param name="appCtx"></param>
        /// <param name="externalLoginsUrl">
        /// The post url used to sign in with external logins - this can change depending on for what service the external login is service.
        /// Example: normal back office login or authenticating upgrade login
        /// </param>
        /// <returns></returns>
        /// <remarks>
        /// These are the bare minimal server variables that are required for the application to start without being authenticated,
        /// we will load the rest of the server vars after the user is authenticated.
        /// </remarks>
        public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, ApplicationContext appCtx, string externalLoginsUrl)
        {
            var serverVars = new BackOfficeServerVariables(uri, appCtx, UmbracoConfig.For.UmbracoSettings());
            var minVars    = serverVars.BareMinimumServerVariables();

            var str = @"<script type=""text/javascript"">
                var Umbraco = {};
                Umbraco.Sys = {};
                Umbraco.Sys.ServerVariables = " + JsonConvert.SerializeObject(minVars) + @";
            </script>";

            return(html.Raw(str));
        }
Beispiel #2
0
        /// <summary>
        /// Outputs a script tag containing the bare minimum (non secure) server vars for use with the angular app
        /// </summary>
        /// <param name="html"></param>
        /// <param name="uri"></param>
        /// <param name="externalLoginsUrl">
        /// The post url used to sign in with external logins - this can change depending on for what service the external login is service.
        /// Example: normal back office login or authenticating upgrade login
        /// </param>
        /// <param name="features"></param>
        /// <param name="globalSettings"></param>
        /// <returns></returns>
        /// <remarks>
        /// These are the bare minimal server variables that are required for the application to start without being authenticated,
        /// we will load the rest of the server vars after the user is authenticated.
        /// </remarks>
        public static IHtmlString BareMinimumServerVariablesScript(this HtmlHelper html, UrlHelper uri, string externalLoginsUrl, UmbracoFeatures features, IGlobalSettings globalSettings)
        {
            var serverVars = new BackOfficeServerVariables(uri, Current.RuntimeState, features, globalSettings);
            var minVars    = serverVars.BareMinimumServerVariables();

            var str = @"<script type=""text/javascript"">
                var Umbraco = {};
                Umbraco.Sys = {};
                Umbraco.Sys.ServerVariables = " + JsonConvert.SerializeObject(minVars) + @";
            </script>";

            return(html.Raw(str));
        }
    /// <summary>
    ///     Outputs a script tag containing the bare minimum (non secure) server vars for use with the angular app
    /// </summary>
    /// <param name="html"></param>
    /// <param name="linkGenerator"></param>
    /// <param name="features"></param>
    /// <param name="globalSettings"></param>
    /// <param name="umbracoVersion"></param>
    /// <param name="contentSettings"></param>
    /// <param name="treeCollection"></param>
    /// <param name="httpContextAccessor"></param>
    /// <param name="hostingEnvironment"></param>
    /// <param name="settings"></param>
    /// <param name="securitySettings"></param>
    /// <param name="runtimeMinifier"></param>
    /// <returns></returns>
    /// <remarks>
    ///     These are the bare minimal server variables that are required for the application to start without being
    ///     authenticated,
    ///     we will load the rest of the server vars after the user is authenticated.
    /// </remarks>
    public static async Task <IHtmlContent> BareMinimumServerVariablesScriptAsync(this IHtmlHelper html,
                                                                                  BackOfficeServerVariables backOfficeServerVariables)
    {
        Dictionary <string, object> minVars = await backOfficeServerVariables.BareMinimumServerVariablesAsync();

        var str = @"<script type=""text/javascript"">
                var Umbraco = {};
                Umbraco.Sys = {};
                Umbraco.Sys.ServerVariables = " + JsonConvert.SerializeObject(minVars) + @";
            </script>";

        return(html.Raw(str));
    }
Beispiel #4
0
 public BackOfficeController(
     IBackOfficeUserManager userManager,
     IRuntimeState runtimeState,
     IRuntimeMinifier runtimeMinifier,
     IOptionsSnapshot <GlobalSettings> globalSettings,
     IHostingEnvironment hostingEnvironment,
     ILocalizedTextService textService,
     IGridConfig gridConfig,
     BackOfficeServerVariables backOfficeServerVariables,
     AppCaches appCaches,
     IBackOfficeSignInManager signInManager,
     IBackOfficeSecurityAccessor backofficeSecurityAccessor,
     ILogger <BackOfficeController> logger,
     IJsonSerializer jsonSerializer,
     IBackOfficeExternalLoginProviders externalLogins,
     IHttpContextAccessor httpContextAccessor,
     IBackOfficeTwoFactorOptions backOfficeTwoFactorOptions,
     IManifestParser manifestParser,
     ServerVariablesParser serverVariables,
     IOptions <SecuritySettings> securitySettings)
 {
     _userManager               = userManager;
     _runtimeState              = runtimeState;
     _runtimeMinifier           = runtimeMinifier;
     _globalSettings            = globalSettings.Value;
     _hostingEnvironment        = hostingEnvironment;
     _textService               = textService;
     _gridConfig                = gridConfig ?? throw new ArgumentNullException(nameof(gridConfig));
     _backOfficeServerVariables = backOfficeServerVariables;
     _appCaches     = appCaches;
     _signInManager = signInManager;
     _backofficeSecurityAccessor = backofficeSecurityAccessor;
     _logger                     = logger;
     _jsonSerializer             = jsonSerializer;
     _externalLogins             = externalLogins;
     _httpContextAccessor        = httpContextAccessor;
     _backOfficeTwoFactorOptions = backOfficeTwoFactorOptions;
     _manifestParser             = manifestParser;
     _serverVariables            = serverVariables;
     _securitySettings           = securitySettings;
 }