using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.Mvc; using Microsoft.Owin.Security; using Newtonsoft.Json; using Umbraco.Web.Editors; namespace Umbraco.Web { /// /// HtmlHelper extensions for the back office /// public static class HtmlHelperBackOfficeExtensions { /// /// Outputs a script tag containing the bare minimum (non secure) server vars for use with the angular app /// /// /// /// /// /// /// 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. /// public static IHtmlString BareMinimumServerVariables(this HtmlHelper html, UrlHelper uri, string umbracoPath) { var str = @""; return html.Raw(str); } /// /// Used to render the script tag that will pass in the angular externalLoginInfo service on page load /// /// /// /// public static IHtmlString AngularExternalLoginInfoValues(this HtmlHelper html, IEnumerable externalLoginErrors) { var loginProviders = html.ViewContext.HttpContext.GetOwinContext().Authentication.GetExternalAuthenticationTypes() .Where(p => p.Properties.ContainsKey("UmbracoBackOffice")) .Select(p => new { authType = p.AuthenticationType, caption = p.Caption, properties = p.Properties }) .ToArray(); //define a callback that is executed when we bootstrap angular, this is used to inject angular values //with server side info var sb = new StringBuilder(@""); return html.Raw(sb.ToString()); } } }