Move UmbracoConfig singleton to Current
This commit is contained in:
@@ -11,12 +11,14 @@ namespace Umbraco.Core.Composing.Composers
|
||||
{
|
||||
public static Composition ComposeConfiguration(this Composition composition)
|
||||
{
|
||||
composition.Register(factory => UmbracoConfig.For.UmbracoSettings());
|
||||
composition.Register(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
composition.Register(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
|
||||
composition.Register(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
|
||||
composition.Register(factory => UmbracoConfig.For.GlobalSettings());
|
||||
composition.Register(factory => UmbracoConfig.For.DashboardSettings());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Umbraco());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Global());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Dashboards());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().HealthChecks());
|
||||
composition.RegisterUnique(factory => factory.GetInstance<UmbracoConfig>().Grids());
|
||||
|
||||
// fixme - other sections we need to add?
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Umbraco.Core.Composing
|
||||
/// </summary>
|
||||
public static void RegisterEssentials(this Composition composition,
|
||||
ILogger logger, IProfiler profiler, IProfilingLogger profilingLogger,
|
||||
IMainDom mainDom,
|
||||
CacheHelper appCaches,
|
||||
IUmbracoDatabaseFactory databaseFactory,
|
||||
TypeLoader typeLoader,
|
||||
@@ -25,6 +26,7 @@ namespace Umbraco.Core.Composing
|
||||
composition.RegisterUnique(logger);
|
||||
composition.RegisterUnique(profiler);
|
||||
composition.RegisterUnique(profilingLogger);
|
||||
composition.RegisterUnique(mainDom);
|
||||
composition.RegisterUnique(appCaches);
|
||||
composition.RegisterUnique(factory => factory.GetInstance<CacheHelper>().RuntimeCache);
|
||||
composition.RegisterUnique(databaseFactory);
|
||||
|
||||
@@ -28,11 +28,18 @@ namespace Umbraco.Core.Composing
|
||||
{
|
||||
private static IFactory _factory;
|
||||
|
||||
// fixme - refactor
|
||||
// we don't want Umbraco tests to die because the container has not been properly initialized,
|
||||
// for some too-important things such as IShortStringHelper or loggers, so if it's not
|
||||
// registered we setup a default one. We should really refactor our tests so that it does
|
||||
// not happen.
|
||||
|
||||
private static IShortStringHelper _shortStringHelper;
|
||||
private static ILogger _logger;
|
||||
private static IProfiler _profiler;
|
||||
private static IProfilingLogger _profilingLogger;
|
||||
private static IPublishedValueFallback _publishedValueFallback;
|
||||
private static UmbracoConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the factory.
|
||||
@@ -73,15 +80,9 @@ namespace Umbraco.Core.Composing
|
||||
|
||||
#region Getters
|
||||
|
||||
// fixme - refactor
|
||||
// we don't want Umbraco to die because the container has not been properly initialized,
|
||||
// for some too-important things such as IShortStringHelper or loggers, so if it's not
|
||||
// registered we setup a default one. We should really refactor our tests so that it does
|
||||
// not happen. Will do when we get rid of IShortStringHelper.
|
||||
|
||||
public static IShortStringHelper ShortStringHelper
|
||||
=> _shortStringHelper ?? (_shortStringHelper = _factory?.TryGetInstance<IShortStringHelper>()
|
||||
?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(UmbracoConfig.For.UmbracoSettings())));
|
||||
?? new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(Config.Umbraco())));
|
||||
|
||||
public static ILogger Logger
|
||||
=> _logger ?? (_logger = _factory?.TryGetInstance<ILogger>()
|
||||
@@ -101,6 +102,10 @@ namespace Umbraco.Core.Composing
|
||||
public static TypeLoader TypeLoader
|
||||
=> Factory.GetInstance<TypeLoader>();
|
||||
|
||||
public static UmbracoConfig Config
|
||||
=> _config ?? (_config = _factory?.TryGetInstance<UmbracoConfig>())
|
||||
?? (_config = new UmbracoConfig(Logger, _factory?.TryGetInstance<IRuntimeCacheProvider>(), _factory?.TryGetInstance<IRuntimeState>()));
|
||||
|
||||
public static IFileSystems FileSystems
|
||||
=> Factory.GetInstance<IFileSystems>();
|
||||
|
||||
|
||||
@@ -7,190 +7,132 @@ using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// The gateway to all umbraco configuration
|
||||
/// The gateway to all umbraco configuration.
|
||||
/// </summary>
|
||||
/// <remarks>This should be registered as a unique service in the container.</remarks>
|
||||
public class UmbracoConfig
|
||||
{
|
||||
#region Singleton
|
||||
|
||||
private static readonly Lazy<UmbracoConfig> Lazy = new Lazy<UmbracoConfig>(() => new UmbracoConfig());
|
||||
|
||||
public static UmbracoConfig For => Lazy.Value;
|
||||
|
||||
#endregion
|
||||
private IGlobalSettings _global;
|
||||
private Lazy<IUmbracoSettingsSection> _umbraco;
|
||||
private Lazy<IHealthChecks> _healthChecks;
|
||||
private Lazy<IDashboardSection> _dashboards;
|
||||
private Lazy<IGridConfig> _grids;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// Initializes a new instance of the <see cref="UmbracoConfig"/> class.
|
||||
/// </summary>
|
||||
private UmbracoConfig()
|
||||
public UmbracoConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, IRuntimeState runtimeState)
|
||||
{
|
||||
_global = new GlobalSettings();
|
||||
|
||||
var appPluginsDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins));
|
||||
var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config));
|
||||
|
||||
_umbraco = new Lazy<IUmbracoSettingsSection>(() => GetConfig<IUmbracoSettingsSection>("umbracoConfiguration/settings"));
|
||||
_dashboards = new Lazy<IDashboardSection>(() =>GetConfig<IDashboardSection>("umbracoConfiguration/dashBoard"));
|
||||
_healthChecks = new Lazy<IHealthChecks>(() => GetConfig<IHealthChecks>("umbracoConfiguration/HealthChecks"));
|
||||
_grids = new Lazy<IGridConfig>(() => new GridConfig(logger, runtimeCache, appPluginsDir, configDir, runtimeState.Debug));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a typed and named config section.
|
||||
/// </summary>
|
||||
/// <typeparam name="TConfig">The type of the configuration section.</typeparam>
|
||||
/// <param name="sectionName">The name of the configuration section.</param>
|
||||
/// <returns>The configuration section.</returns>
|
||||
public static TConfig GetConfig<TConfig>(string sectionName)
|
||||
where TConfig : class
|
||||
{
|
||||
// note: need to use SafeCallContext here because ConfigurationManager.GetSection ends up getting AppDomain.Evidence
|
||||
// which will want to serialize the call context including anything that is in there - what a mess!
|
||||
|
||||
if (_umbracoSettings == null)
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
IUmbracoSettingsSection umbracoSettings;
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
umbracoSettings = ConfigurationManager.GetSection("umbracoConfiguration/settings") as IUmbracoSettingsSection;
|
||||
}
|
||||
SetUmbracoSettings(umbracoSettings);
|
||||
}
|
||||
|
||||
if (_dashboardSection == null)
|
||||
{
|
||||
IDashboardSection dashboardConfig;
|
||||
using (new SafeCallContext())
|
||||
{
|
||||
dashboardConfig = ConfigurationManager.GetSection("umbracoConfiguration/dashBoard") as IDashboardSection;
|
||||
}
|
||||
SetDashboardSettings(dashboardConfig);
|
||||
}
|
||||
|
||||
if (_healthChecks == null)
|
||||
{
|
||||
var healthCheckConfig = ConfigurationManager.GetSection("umbracoConfiguration/HealthChecks") as IHealthChecks;
|
||||
SetHealthCheckSettings(healthCheckConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor - can be used for testing
|
||||
/// </summary>
|
||||
/// <param name="umbracoSettings"></param>
|
||||
/// <param name="dashboardSettings"></param>
|
||||
/// <param name="healthChecks"></param>
|
||||
/// <param name="globalSettings"></param>
|
||||
public UmbracoConfig(IUmbracoSettingsSection umbracoSettings, IDashboardSection dashboardSettings, IHealthChecks healthChecks, IGlobalSettings globalSettings)
|
||||
{
|
||||
SetHealthCheckSettings(healthChecks);
|
||||
SetUmbracoSettings(umbracoSettings);
|
||||
SetDashboardSettings(dashboardSettings);
|
||||
SetGlobalConfig(globalSettings);
|
||||
}
|
||||
|
||||
private IHealthChecks _healthChecks;
|
||||
private IDashboardSection _dashboardSection;
|
||||
private IUmbracoSettingsSection _umbracoSettings;
|
||||
private IGridConfig _gridConfig;
|
||||
private IGlobalSettings _globalSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IHealthCheck config
|
||||
/// </summary>
|
||||
public IHealthChecks HealthCheck()
|
||||
{
|
||||
if (_healthChecks == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof(IHealthChecks) + " from config file, ensure the web.config and healthchecks.config files are formatted correctly");
|
||||
if ((ConfigurationManager.GetSection(sectionName) is TConfig config))
|
||||
return config;
|
||||
var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files.");
|
||||
Current.Logger.Error<UmbracoConfig>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _healthChecks;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IDashboardSection
|
||||
/// Gets the global configuration.
|
||||
/// </summary>
|
||||
public IDashboardSection DashboardSettings()
|
||||
{
|
||||
if (_dashboardSection == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof(IDashboardSection) + " from config file, ensure the web.config and Dashboard.config files are formatted correctly");
|
||||
Current.Logger.Error<UmbracoConfig>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _dashboardSection;
|
||||
}
|
||||
public IGlobalSettings Global()
|
||||
=> _global;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the Umbraco configuration.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetDashboardSettings(IDashboardSection value)
|
||||
{
|
||||
_dashboardSection = value;
|
||||
}
|
||||
public IUmbracoSettingsSection Umbraco()
|
||||
=> _umbraco.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the dashboards configuration.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetHealthCheckSettings(IHealthChecks value)
|
||||
{
|
||||
_healthChecks = value;
|
||||
}
|
||||
public IDashboardSection Dashboards()
|
||||
=> _dashboards.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the health checks configuration.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetUmbracoSettings(IUmbracoSettingsSection value)
|
||||
{
|
||||
_umbracoSettings = value;
|
||||
}
|
||||
public IHealthChecks HealthChecks()
|
||||
=> _healthChecks.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Gets the grids configuration.
|
||||
/// </summary>
|
||||
public IGridConfig Grids()
|
||||
=> _grids.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the global configuration, for tests only.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetGlobalConfig(IGlobalSettings value)
|
||||
{
|
||||
_globalSettings = value;
|
||||
_global = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IGlobalSettings
|
||||
/// Sets the Umbraco configuration, for tests only.
|
||||
/// </summary>
|
||||
public IGlobalSettings GlobalSettings()
|
||||
public void SetUmbracoConfig(IUmbracoSettingsSection value)
|
||||
{
|
||||
return _globalSettings ?? (_globalSettings = new GlobalSettings());
|
||||
_umbraco = new Lazy<IUmbracoSettingsSection>(() => value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IUmbracoSettings
|
||||
/// </summary>
|
||||
public IUmbracoSettingsSection UmbracoSettings()
|
||||
{
|
||||
if (_umbracoSettings == null)
|
||||
{
|
||||
var ex = new ConfigurationErrorsException("Could not load the " + typeof (IUmbracoSettingsSection) + " from config file, ensure the web.config and umbracoSettings.config files are formatted correctly");
|
||||
Current.Logger.Error<UmbracoConfig>(ex, "Config error");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return _umbracoSettings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Only for testing
|
||||
/// Sets the dashboards configuration, for tests only.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetGridConfig(IGridConfig value)
|
||||
public void SetDashboardsConfig(IDashboardSection value)
|
||||
{
|
||||
_gridConfig = value;
|
||||
_dashboards = new Lazy<IDashboardSection>(() => value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the IGridConfig
|
||||
/// Sets the health checks configuration, for tests only.
|
||||
/// </summary>
|
||||
public IGridConfig GridConfig(ILogger logger, IRuntimeCacheProvider runtimeCache, DirectoryInfo appPlugins, DirectoryInfo configFolder, bool isDebug)
|
||||
public void SetHealthChecksConfig(IHealthChecks value)
|
||||
{
|
||||
if (_gridConfig == null)
|
||||
{
|
||||
_gridConfig = new GridConfig(logger, runtimeCache, appPlugins, configFolder, isDebug);
|
||||
}
|
||||
_healthChecks = new Lazy<IHealthChecks>(() => value);
|
||||
}
|
||||
|
||||
return _gridConfig;
|
||||
/// <summary>
|
||||
/// Sets the grids configuration, for tests only.
|
||||
/// </summary>
|
||||
public void SetGridsConfig(IGridConfig value)
|
||||
{
|
||||
_grids = new Lazy<IGridConfig>(() => value);
|
||||
}
|
||||
|
||||
//TODO: Add other configurations here !
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
@@ -30,7 +31,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
// prevpath should be "<int>/<filename>" OR "<int>-<filename>"
|
||||
// and we want to reuse the "<int>" part, so try to find it
|
||||
|
||||
var sep = UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories ? "/" : "-";
|
||||
var sep = Current.Config.Umbraco().Content.UploadAllowDirectories ? "/" : "-";
|
||||
var pos = previous.IndexOf(sep, StringComparison.Ordinal);
|
||||
var s = pos > 0 ? previous.Substring(0, pos) : null;
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace Umbraco.Core.IO.MediaPathSchemes
|
||||
if (directory == null)
|
||||
throw new InvalidOperationException("Cannot use a null directory.");
|
||||
|
||||
return UmbracoConfig.For.UmbracoSettings().Content.UploadAllowDirectories
|
||||
return Current.Config.Umbraco().Content.UploadAllowDirectories
|
||||
? Path.Combine(directory, filename).Replace('\\', '/')
|
||||
: directory + "-" + filename;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Diagnostics;
|
||||
|
||||
@@ -165,7 +166,7 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
messageTemplate += "\r\nThe thread has been aborted, because the request has timed out.";
|
||||
|
||||
// dump if configured, or if stacktrace contains Monitor.ReliableEnter
|
||||
dump = UmbracoConfig.For.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
dump = Current.Config.CoreDebug().DumpOnTimeoutThreadAbort || IsMonitorEnterThreadAbortException(exception);
|
||||
|
||||
// dump if it is ok to dump (might have a cap on number of dump...)
|
||||
dump &= MiniDump.OkToDump();
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Core
|
||||
/// <para>When an AppDomain starts, it tries to acquire the main domain status.</para>
|
||||
/// <para>When an AppDomain stops (eg the application is restarting) it should release the main domain status.</para>
|
||||
/// </remarks>
|
||||
internal class MainDom : IRegisteredObject
|
||||
internal class MainDom : IMainDom, IRegisteredObject
|
||||
{
|
||||
#region Vars
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
@@ -66,7 +67,7 @@ namespace Umbraco.Core.Models.Identity
|
||||
_startContentIds = new int[] { };
|
||||
_groups = new IReadOnlyUserGroup[] { };
|
||||
_allowedSections = new string[] { };
|
||||
_culture = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
|
||||
_culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_groups = new IReadOnlyUserGroup[0];
|
||||
_roles = new ObservableCollection<IdentityUserRole<string>>();
|
||||
_roles.CollectionChanged += _roles_CollectionChanged;
|
||||
@@ -83,7 +84,7 @@ namespace Umbraco.Core.Models.Identity
|
||||
_startContentIds = new int[] { };
|
||||
_groups = new IReadOnlyUserGroup[] { };
|
||||
_allowedSections = new string[] { };
|
||||
_culture = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
|
||||
_culture = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_groups = groups.ToArray();
|
||||
_roles = new ObservableCollection<IdentityUserRole<string>>(_groups.Select(x => new IdentityUserRole<string>
|
||||
{
|
||||
@@ -442,6 +443,6 @@ namespace Umbraco.Core.Models.Identity
|
||||
groups => groups.GetHashCode());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
{
|
||||
SessionTimeout = 60;
|
||||
_userGroups = new HashSet<IReadOnlyUserGroup>();
|
||||
_language = UmbracoConfig.For.GlobalSettings().DefaultUILanguage; //fixme inject somehow?
|
||||
_language = Current.Config.Global().DefaultUILanguage; //fixme inject somehow?
|
||||
_isApproved = true;
|
||||
_isLockedOut = false;
|
||||
_startContentIds = new int[] { };
|
||||
@@ -453,7 +453,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
base.PerformDeepClone(clone);
|
||||
|
||||
var clonedEntity = (User)clone;
|
||||
|
||||
|
||||
//manually clone the start node props
|
||||
clonedEntity._startContentIds = _startContentIds.ToArray();
|
||||
clonedEntity._startMediaIds = _startMediaIds.ToArray();
|
||||
@@ -483,7 +483,7 @@ namespace Umbraco.Core.Models.Membership
|
||||
//need to create new collections otherwise they'll get copied by ref
|
||||
clonedEntity._userGroups = new HashSet<IReadOnlyUserGroup>(_userGroups);
|
||||
clonedEntity._allowedSections = _allowedSections != null ? new List<string>(_allowedSections) : null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration.Grid;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
@@ -19,9 +20,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
[DefaultPropertyValueConverter(typeof(JsonValueConverter))] //this shadows the JsonValueConverter
|
||||
public class GridValueConverter : JsonValueConverter
|
||||
{
|
||||
public GridValueConverter(PropertyEditorCollection propertyEditors)
|
||||
private readonly IGridConfig _config;
|
||||
|
||||
public GridValueConverter(PropertyEditorCollection propertyEditors, IGridConfig config)
|
||||
: base(propertyEditors)
|
||||
{ }
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.Grid);
|
||||
@@ -46,15 +51,6 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
//so we have the grid json... we need to merge in the grid's configuration values with the values
|
||||
// we've saved in the database so that when the front end gets this value, it is up-to-date.
|
||||
|
||||
//TODO: Change all singleton access to use ctor injection in v8!!!
|
||||
//TODO: That would mean that property value converters would need to be request lifespan, hrm....
|
||||
var gridConfig = UmbracoConfig.For.GridConfig(
|
||||
Current.ProfilingLogger,
|
||||
Current.ApplicationCache.RuntimeCache,
|
||||
new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins)),
|
||||
new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)),
|
||||
Current.RuntimeState.Debug);
|
||||
|
||||
var sections = GetArray(obj, "sections");
|
||||
foreach (var section in sections.Cast<JObject>())
|
||||
{
|
||||
@@ -74,7 +70,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
if (alias.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
//find the alias in config
|
||||
var found = gridConfig.EditorsConfig.Editors.FirstOrDefault(x => x.Alias == alias);
|
||||
var found = _config.EditorsConfig.Editors.FirstOrDefault(x => x.Alias == alias);
|
||||
if (found != null)
|
||||
{
|
||||
//add/replace the editor value with the one from config
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Core.Runtime
|
||||
var databaseFactory = GetDatabaseFactory();
|
||||
|
||||
// type loader
|
||||
var globalSettings = UmbracoConfig.For.GlobalSettings();
|
||||
var globalSettings = Current.Config.Global();
|
||||
var localTempStorage = globalSettings.LocalTempStorageLocation;
|
||||
var typeLoader = new TypeLoader(runtimeCache, localTempStorage, profilingLogger);
|
||||
|
||||
@@ -77,16 +77,19 @@ namespace Umbraco.Core.Runtime
|
||||
// beware! must use '() => _factory.GetInstance<T>()' and NOT '_factory.GetInstance<T>'
|
||||
// as the second one captures the current value (null) and therefore fails
|
||||
_state = new RuntimeState(logger,
|
||||
UmbracoConfig.For.UmbracoSettings(), UmbracoConfig.For.GlobalSettings(),
|
||||
Current.Config.Umbraco(), Current.Config.Global(),
|
||||
new Lazy<MainDom>(() => _factory.GetInstance<MainDom>()),
|
||||
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()))
|
||||
{
|
||||
Level = RuntimeLevel.Boot
|
||||
};
|
||||
|
||||
// main dom
|
||||
var mainDom = new MainDom(logger);
|
||||
|
||||
// create the composition
|
||||
var composition = new Composition(register, typeLoader, profilingLogger, _state);
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, appCaches, databaseFactory, typeLoader, _state);
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state);
|
||||
|
||||
// register runtime-level services
|
||||
// there should be none, really - this is here "just in case"
|
||||
@@ -113,8 +116,7 @@ namespace Umbraco.Core.Runtime
|
||||
|
||||
logger.Debug<CoreRuntime>("Runtime: {Runtime}", GetType().FullName);
|
||||
|
||||
var mainDom = AquireMainDom();
|
||||
composition.RegisterUnique(mainDom);
|
||||
AquireMainDom(mainDom);
|
||||
|
||||
DetermineRuntimeLevel(databaseFactory);
|
||||
|
||||
@@ -195,15 +197,13 @@ namespace Umbraco.Core.Runtime
|
||||
IOHelper.SetRootDirectory(path);
|
||||
}
|
||||
|
||||
private MainDom AquireMainDom()
|
||||
private void AquireMainDom(MainDom mainDom)
|
||||
{
|
||||
using (var timer = ProfilingLogger.DebugDuration<CoreRuntime>("Acquiring MainDom.", "Acquired."))
|
||||
{
|
||||
try
|
||||
{
|
||||
var mainDom = new MainDom(Logger);
|
||||
mainDom.Acquire();
|
||||
return mainDom;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -491,7 +492,7 @@ namespace Umbraco.Core.Scoping
|
||||
// caching config
|
||||
// true if Umbraco.CoreDebug.LogUncompletedScope appSetting is set to "true"
|
||||
private static bool LogUncompletedScopes => (_logUncompletedScopes
|
||||
?? (_logUncompletedScopes = UmbracoConfig.For.CoreDebug().LogUncompletedScopes)).Value;
|
||||
?? (_logUncompletedScopes = Current.Config.CoreDebug().LogUncompletedScopes)).Value;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ReadLock(params int[] lockIds)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.Web.Security;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -87,11 +88,11 @@ namespace Umbraco.Core.Security
|
||||
/// <returns></returns>
|
||||
public static MembershipProvider GetUsersMembershipProvider()
|
||||
{
|
||||
if (Membership.Providers[UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider] == null)
|
||||
if (Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider] == null)
|
||||
{
|
||||
throw new InvalidOperationException("No membership provider found with name " + UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider);
|
||||
throw new InvalidOperationException("No membership provider found with name " + Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider);
|
||||
}
|
||||
return Membership.Providers[UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider];
|
||||
return Membership.Providers[Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1115,7 +1115,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>Checks <c>UmbracoSettings.ForceSafeAliases</c> to determine whether it should filter the text.</remarks>
|
||||
public static string ToSafeAliasWithForcingCheck(this string alias)
|
||||
{
|
||||
return UmbracoConfig.For.UmbracoSettings().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias;
|
||||
return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias() : alias;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1127,7 +1127,7 @@ namespace Umbraco.Core
|
||||
/// <remarks>Checks <c>UmbracoSettings.ForceSafeAliases</c> to determine whether it should filter the text.</remarks>
|
||||
public static string ToSafeAliasWithForcingCheck(this string alias, string culture)
|
||||
{
|
||||
return UmbracoConfig.For.UmbracoSettings().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias;
|
||||
return Current.Config.Umbraco().Content.ForceSafeAliases ? alias.ToSafeAlias(culture) : alias;
|
||||
}
|
||||
|
||||
// the new methods to get a url segment
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Web.Routing;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -50,7 +51,7 @@ namespace Umbraco.Tests.Configurations
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
SystemDirectories.Root = rootPath;
|
||||
Assert.AreEqual(outcome, UmbracoConfig.For.GlobalSettings().GetUmbracoMvcArea());
|
||||
Assert.AreEqual(outcome, Current.Config.Global().GetUmbracoMvcArea());
|
||||
}
|
||||
|
||||
[TestCase("/umbraco/umbraco.aspx")]
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.IO
|
||||
private static void ClearFiles()
|
||||
{
|
||||
TestHelper.DeleteDirectory(IOHelper.MapPath("FileSysTests"));
|
||||
TestHelper.DeleteDirectory(IOHelper.MapPath("App_Data"));
|
||||
TestHelper.DeleteDirectory(IOHelper.MapPath("App_Data/TEMP/ShadowFs"));
|
||||
}
|
||||
|
||||
private static string NormPath(string path)
|
||||
@@ -388,9 +388,9 @@ namespace Umbraco.Tests.IO
|
||||
var logger = Mock.Of<ILogger>();
|
||||
|
||||
var path = IOHelper.MapPath("FileSysTests");
|
||||
var appdata = IOHelper.MapPath("App_Data");
|
||||
var shadowfs = IOHelper.MapPath("App_Data/TEMP/ShadowFs");
|
||||
Directory.CreateDirectory(path);
|
||||
Directory.CreateDirectory(appdata);
|
||||
Directory.CreateDirectory(shadowfs);
|
||||
|
||||
var scopedFileSystems = false;
|
||||
|
||||
@@ -409,24 +409,24 @@ namespace Umbraco.Tests.IO
|
||||
|
||||
// explicit shadow without scope does not work
|
||||
sw.Shadow(id = Guid.NewGuid());
|
||||
Assert.IsTrue(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsTrue(Directory.Exists(shadowfs + "/" + id));
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
|
||||
sw.AddFile("sub/f2.txt", ms);
|
||||
Assert.IsTrue(phy.FileExists("sub/f2.txt"));
|
||||
sw.UnShadow(true);
|
||||
Assert.IsTrue(phy.FileExists("sub/f2.txt"));
|
||||
Assert.IsFalse(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsFalse(Directory.Exists(shadowfs + "/" + id));
|
||||
|
||||
// shadow with scope but no complete does not complete
|
||||
scopedFileSystems = true; // pretend we have a scope
|
||||
var scope = new ShadowFileSystems(fileSystems, id = Guid.NewGuid());
|
||||
Assert.IsTrue(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsTrue(Directory.Exists(shadowfs + "/" + id));
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
|
||||
sw.AddFile("sub/f3.txt", ms);
|
||||
Assert.IsFalse(phy.FileExists("sub/f3.txt"));
|
||||
var dirs = Directory.GetDirectories(appdata + "/TEMP/ShadowFs");
|
||||
var dirs = Directory.GetDirectories(shadowfs);
|
||||
Assert.AreEqual(1, dirs.Length);
|
||||
Assert.AreEqual((appdata + "/TEMP/ShadowFs/" + id).Replace('\\', '/'), dirs[0].Replace('\\', '/'));
|
||||
Assert.AreEqual((shadowfs + "/" + id).Replace('\\', '/'), dirs[0].Replace('\\', '/'));
|
||||
dirs = Directory.GetDirectories(dirs[0]);
|
||||
var typedDir = dirs.FirstOrDefault(x => x.Replace('\\', '/').EndsWith("/typed"));
|
||||
Assert.IsNotNull(typedDir);
|
||||
@@ -436,28 +436,28 @@ namespace Umbraco.Tests.IO
|
||||
scope.Dispose();
|
||||
scopedFileSystems = false;
|
||||
Assert.IsFalse(phy.FileExists("sub/f3.txt"));
|
||||
TestHelper.TryAssert(() => Assert.IsFalse(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id)));
|
||||
TestHelper.TryAssert(() => Assert.IsFalse(Directory.Exists(shadowfs + "/" + id)));
|
||||
|
||||
// shadow with scope and complete does complete
|
||||
scopedFileSystems = true; // pretend we have a scope
|
||||
scope = new ShadowFileSystems(fileSystems, id = Guid.NewGuid());
|
||||
Assert.IsTrue(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsTrue(Directory.Exists(shadowfs + "/" + id));
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
|
||||
sw.AddFile("sub/f4.txt", ms);
|
||||
Assert.IsFalse(phy.FileExists("sub/f4.txt"));
|
||||
Assert.AreEqual(1, Directory.GetDirectories(appdata + "/TEMP/ShadowFs").Length);
|
||||
Assert.AreEqual(1, Directory.GetDirectories(shadowfs).Length);
|
||||
scope.Complete();
|
||||
scope.Dispose();
|
||||
scopedFileSystems = false;
|
||||
TestHelper.TryAssert(() => Assert.AreEqual(0, Directory.GetDirectories(appdata + "/TEMP/ShadowFs").Length));
|
||||
TestHelper.TryAssert(() => Assert.AreEqual(0, Directory.GetDirectories(shadowfs).Length));
|
||||
Assert.IsTrue(phy.FileExists("sub/f4.txt"));
|
||||
Assert.IsFalse(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsFalse(Directory.Exists(shadowfs + "/" + id));
|
||||
|
||||
// test scope for "another thread"
|
||||
|
||||
scopedFileSystems = true; // pretend we have a scope
|
||||
scope = new ShadowFileSystems(fileSystems, id = Guid.NewGuid());
|
||||
Assert.IsTrue(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsTrue(Directory.Exists(shadowfs + "/" + id));
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
|
||||
sw.AddFile("sub/f5.txt", ms);
|
||||
Assert.IsFalse(phy.FileExists("sub/f5.txt"));
|
||||
@@ -473,7 +473,7 @@ namespace Umbraco.Tests.IO
|
||||
scope.Dispose();
|
||||
scopedFileSystems = false;
|
||||
Assert.IsTrue(phy.FileExists("sub/f5.txt"));
|
||||
Assert.IsFalse(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsFalse(Directory.Exists(shadowfs + "/" + id));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -482,7 +482,7 @@ namespace Umbraco.Tests.IO
|
||||
var logger = Mock.Of<ILogger>();
|
||||
|
||||
var path = IOHelper.MapPath("FileSysTests");
|
||||
var appdata = IOHelper.MapPath("App_Data");
|
||||
var shadowfs = IOHelper.MapPath("App_Data/TEMP/ShadowFs");
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var scopedFileSystems = false;
|
||||
@@ -502,7 +502,7 @@ namespace Umbraco.Tests.IO
|
||||
|
||||
scopedFileSystems = true; // pretend we have a scope
|
||||
var scope = new ShadowFileSystems(fileSystems, id = Guid.NewGuid());
|
||||
Assert.IsTrue(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsTrue(Directory.Exists(shadowfs + "/" + id));
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
|
||||
sw.AddFile("sub/f2.txt", ms);
|
||||
Assert.IsFalse(phy.FileExists("sub/f2.txt"));
|
||||
@@ -518,7 +518,7 @@ namespace Umbraco.Tests.IO
|
||||
scope.Dispose();
|
||||
scopedFileSystems = false;
|
||||
Assert.IsTrue(phy.FileExists("sub/f2.txt"));
|
||||
TestHelper.TryAssert(() => Assert.IsFalse(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id)));
|
||||
TestHelper.TryAssert(() => Assert.IsFalse(Directory.Exists(shadowfs + "/" + id)));
|
||||
|
||||
string text;
|
||||
using (var s = phy.OpenFile("sub/f2.txt"))
|
||||
@@ -535,7 +535,7 @@ namespace Umbraco.Tests.IO
|
||||
var logger = Mock.Of<ILogger>();
|
||||
|
||||
var path = IOHelper.MapPath("FileSysTests");
|
||||
var appdata = IOHelper.MapPath("App_Data");
|
||||
var shadowfs = IOHelper.MapPath("App_Data/TEMP/ShadowFs");
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
var scopedFileSystems = false;
|
||||
@@ -555,7 +555,7 @@ namespace Umbraco.Tests.IO
|
||||
|
||||
scopedFileSystems = true; // pretend we have a scope
|
||||
var scope = new ShadowFileSystems(fileSystems, id = Guid.NewGuid());
|
||||
Assert.IsTrue(Directory.Exists(appdata + "/TEMP/ShadowFs/" + id));
|
||||
Assert.IsTrue(Directory.Exists(shadowfs + "/" + id));
|
||||
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
|
||||
sw.AddFile("sub/f2.txt", ms);
|
||||
Assert.IsFalse(phy.FileExists("sub/f2.txt"));
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Web.UI.WebControls;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -26,7 +27,7 @@ namespace Umbraco.Tests.Macros
|
||||
new IsolatedRuntimeCache(type => new ObjectCacheRuntimeCacheProvider()));
|
||||
//Current.ApplicationContext = new ApplicationContext(cacheHelper, new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
|
||||
UmbracoConfig.For.SetUmbracoSettings(SettingsForTests.GetDefaultUmbracoSettings());
|
||||
Current.Config.SetUmbracoConfig(SettingsForTests.GetDefaultUmbracoSettings());
|
||||
}
|
||||
|
||||
[TestCase("123", "IntProp", typeof(int))]
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Data;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -35,7 +36,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
// use any local db files, does not rely on any database) - and tests variations
|
||||
|
||||
SettingsForTests.ConfigureSettings(SettingsForTests.GenerateMockUmbracoSettings());
|
||||
var globalSettings = UmbracoConfig.For.GlobalSettings();
|
||||
var globalSettings = Current.Config.Global();
|
||||
|
||||
// create a content node kit
|
||||
var kit = new ContentNodeKit
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Globalization;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Tests.Routing
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
var lookup = new ContentFinderByUrl(Logger);
|
||||
|
||||
Assert.IsTrue(UmbracoConfig.For.GlobalSettings().HideTopLevelNodeFromPath);
|
||||
Assert.IsTrue(Current.Config.Global().HideTopLevelNodeFromPath);
|
||||
|
||||
// fixme debugging - going further down, the routes cache is NOT empty?!
|
||||
if (urlString == "/home/sub1")
|
||||
@@ -66,13 +67,13 @@ namespace Umbraco.Tests.Routing
|
||||
var globalSettingsMock = Mock.Get(TestObjects.GetGlobalSettings()); //this will modify the IGlobalSettings instance stored in the container
|
||||
globalSettingsMock.Setup(x => x.HideTopLevelNodeFromPath).Returns(false);
|
||||
SettingsForTests.ConfigureSettings(globalSettingsMock.Object);
|
||||
|
||||
|
||||
var umbracoContext = GetUmbracoContext(urlString, globalSettings:globalSettingsMock.Object);
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
var lookup = new ContentFinderByUrl(Logger);
|
||||
|
||||
Assert.IsFalse(UmbracoConfig.For.GlobalSettings().HideTopLevelNodeFromPath);
|
||||
Assert.IsFalse(Current.Config.Global().HideTopLevelNodeFromPath);
|
||||
|
||||
var result = lookup.TryFindContent(frequest);
|
||||
|
||||
@@ -97,7 +98,7 @@ namespace Umbraco.Tests.Routing
|
||||
var publishedRouter = CreatePublishedRouter();
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
var lookup = new ContentFinderByUrl(Logger);
|
||||
|
||||
|
||||
var result = lookup.TryFindContent(frequest);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
@@ -156,7 +157,7 @@ namespace Umbraco.Tests.Routing
|
||||
var frequest = publishedRouter.CreateRequest(umbracoContext);
|
||||
frequest.Domain = new DomainAndUri(new Domain(1, "mysite/æøå", -1, CultureInfo.CurrentCulture, false), new Uri("http://mysite/æøå"));
|
||||
var lookup = new ContentFinderByUrl(Logger);
|
||||
|
||||
|
||||
var result = lookup.TryFindContent(frequest);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
|
||||
@@ -134,12 +134,12 @@ namespace Umbraco.Tests.Runtimes
|
||||
composition.RegisterUnique(scopeProvider);
|
||||
}
|
||||
|
||||
private MainDom _mainDom;
|
||||
private IMainDom _mainDom;
|
||||
|
||||
public override IFactory Boot(IRegister container)
|
||||
{
|
||||
var factory = base.Boot(container);
|
||||
_mainDom = factory.GetInstance<MainDom>();
|
||||
_mainDom = factory.GetInstance<IMainDom>();
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
@@ -23,7 +21,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
{
|
||||
[Test]
|
||||
[Explicit("This test must be run manually")]
|
||||
public void Test()
|
||||
public void ValidateComposition()
|
||||
{
|
||||
// this is almost what CoreRuntime does, without
|
||||
// - managing MainDom
|
||||
@@ -40,27 +38,18 @@ namespace Umbraco.Tests.Runtimes
|
||||
var typeLoader = new TypeLoader(appCaches.RuntimeCache, LocalTempStorage.Default, profilingLogger);
|
||||
var runtimeState = Mock.Of<IRuntimeState>();
|
||||
Mock.Get(runtimeState).Setup(x => x.Level).Returns(RuntimeLevel.Run);
|
||||
var mainDom = Mock.Of<IMainDom>();
|
||||
Mock.Get(mainDom).Setup(x => x.IsMainDom).Returns(true);
|
||||
|
||||
// create the register and the composition
|
||||
var register = RegisterFactory.Create();
|
||||
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState);
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, appCaches, databaseFactory, typeLoader, runtimeState);
|
||||
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState);
|
||||
|
||||
// create the core runtime and have it compose itself
|
||||
var coreRuntime = new CoreRuntime();
|
||||
coreRuntime.Compose(composition);
|
||||
|
||||
// fixme
|
||||
// at that point, CoreRuntime also does
|
||||
//composition.RegisterUnique(mainDom)
|
||||
// we should make it
|
||||
composition.RegisterUnique(Mock.Of<IMainDom>());
|
||||
//composition.RegisterUnique<IMainDom>(new SimpleMainDom());
|
||||
// because some components want to use it
|
||||
// (and then, what would a standalone maindom be?)
|
||||
//
|
||||
// is this an essential thing then??
|
||||
|
||||
// get the components
|
||||
// all of them?
|
||||
var componentTypes = typeLoader.GetTypes<IUmbracoComponent>();
|
||||
@@ -92,34 +81,45 @@ namespace Umbraco.Tests.Runtimes
|
||||
foreach (var result in resultGroup)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"{result.Severity}: {WordWrap(result.Message, 120)}");
|
||||
var target = result.ValidationTarget;
|
||||
Console.Write("\tsvce: ");
|
||||
Console.Write(target.ServiceName);
|
||||
Console.Write(target.DeclaringService.ServiceType);
|
||||
if (!target.DeclaringService.ServiceName.IsNullOrWhiteSpace())
|
||||
{
|
||||
Console.Write(" '");
|
||||
Console.Write(target.DeclaringService.ServiceName);
|
||||
Console.Write("'");
|
||||
}
|
||||
|
||||
Console.Write(" (");
|
||||
if (target.DeclaringService.Lifetime == null)
|
||||
Console.Write("?");
|
||||
else
|
||||
Console.Write(target.DeclaringService.Lifetime.ToString().TrimStart("LightInject."));
|
||||
Console.WriteLine(")");
|
||||
Console.Write("\timpl: ");
|
||||
Console.WriteLine(target.DeclaringService.ImplementingType);
|
||||
Console.Write("\tparm: ");
|
||||
Console.Write(target.Parameter);
|
||||
Console.WriteLine();
|
||||
Console.Write(ToText(result));
|
||||
}
|
||||
|
||||
Assert.AreEqual(0, results.Count);
|
||||
}
|
||||
|
||||
public static string WordWrap(string text, int width)
|
||||
private static string ToText(ValidationResult result)
|
||||
{
|
||||
var text = new StringBuilder();
|
||||
|
||||
text.AppendLine($"{result.Severity}: {WordWrap(result.Message, 120)}");
|
||||
var target = result.ValidationTarget;
|
||||
text.Append("\tsvce: ");
|
||||
text.Append(target.ServiceName);
|
||||
text.Append(target.DeclaringService.ServiceType);
|
||||
if (!target.DeclaringService.ServiceName.IsNullOrWhiteSpace())
|
||||
{
|
||||
text.Append(" '");
|
||||
text.Append(target.DeclaringService.ServiceName);
|
||||
text.Append("'");
|
||||
}
|
||||
|
||||
text.Append(" (");
|
||||
if (target.DeclaringService.Lifetime == null)
|
||||
text.Append("Transient");
|
||||
else
|
||||
text.Append(target.DeclaringService.Lifetime.ToString().TrimStart("LightInject.").TrimEnd("Lifetime"));
|
||||
text.AppendLine(")");
|
||||
text.Append("\timpl: ");
|
||||
text.Append(target.DeclaringService.ImplementingType);
|
||||
text.AppendLine();
|
||||
text.Append("\tparm: ");
|
||||
text.Append(target.Parameter);
|
||||
text.AppendLine();
|
||||
|
||||
return text.ToString();
|
||||
}
|
||||
|
||||
private static string WordWrap(string text, int width)
|
||||
{
|
||||
int pos, next;
|
||||
var sb = new StringBuilder();
|
||||
@@ -169,7 +169,7 @@ namespace Umbraco.Tests.Runtimes
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static int BreakLine(string text, int pos, int max)
|
||||
private static int BreakLine(string text, int pos, int max)
|
||||
{
|
||||
// Find last whitespace in line
|
||||
var i = max - 1;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Scoping
|
||||
{
|
||||
TestHelper.DeleteDirectory(IOHelper.MapPath("media"));
|
||||
TestHelper.DeleteDirectory(IOHelper.MapPath("FileSysTests"));
|
||||
TestHelper.DeleteDirectory(IOHelper.MapPath("App_Data"));
|
||||
TestHelper.DeleteDirectory(IOHelper.MapPath("App_Data/TEMP/ShadowFs"));
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Configuration;
|
||||
using Moq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.IO;
|
||||
@@ -13,7 +14,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
public static void ConfigureSettings(IGlobalSettings settings)
|
||||
{
|
||||
UmbracoConfig.For.SetGlobalConfig(settings);
|
||||
Current.Config.SetGlobalConfig(settings);
|
||||
}
|
||||
|
||||
// umbracoSettings
|
||||
@@ -24,7 +25,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
/// <param name="settings"></param>
|
||||
public static void ConfigureSettings(IUmbracoSettingsSection settings)
|
||||
{
|
||||
UmbracoConfig.For.SetUmbracoSettings(settings);
|
||||
Current.Config.SetUmbracoConfig(settings);
|
||||
}
|
||||
|
||||
public static IGlobalSettings GenerateMockGlobalSettings()
|
||||
@@ -103,7 +104,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
// SaveSetting("umbracoConfigurationStatus");
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
// reset & defaults
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Umbraco.Tests.Web
|
||||
|
||||
Udi.ResetUdiTypes();
|
||||
|
||||
UmbracoConfig.For.SetUmbracoSettings(SettingsForTests.GetDefaultUmbracoSettings());
|
||||
Current.Config.SetUmbracoConfig(SettingsForTests.GetDefaultUmbracoSettings());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Web.UI.Umbraco
|
||||
@@ -13,7 +14,7 @@ namespace Umbraco.Web.UI.Umbraco
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Response.Status = "301 Moved Permanently";
|
||||
Response.AddHeader("Location", UmbracoConfig.For.GlobalSettings().Path);
|
||||
Response.AddHeader("Location", Current.Config.Global().Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -200,6 +201,8 @@ namespace Umbraco.Web.Composing
|
||||
|
||||
public static TypeLoader TypeLoader => CoreCurrent.TypeLoader;
|
||||
|
||||
public static UmbracoConfig Config => CoreCurrent.Config;
|
||||
|
||||
public static UrlSegmentProviderCollection UrlSegmentProviders => CoreCurrent.UrlSegmentProviders;
|
||||
|
||||
public static CacheRefresherCollection CacheRefreshers => CoreCurrent.CacheRefreshers;
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
// If this feature is switched off in configuration the UI will be amended to not make the request to reset password available.
|
||||
// So this is just a server-side secondary check.
|
||||
if (UmbracoConfig.For.UmbracoSettings().Security.AllowPasswordReset == false)
|
||||
if (Current.Config.Umbraco().Security.AllowPasswordReset == false)
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.BadRequest);
|
||||
}
|
||||
|
||||
@@ -233,13 +233,7 @@ namespace Umbraco.Web.Editors
|
||||
[HttpGet]
|
||||
public JsonNetResult GetGridConfig()
|
||||
{
|
||||
var gridConfig = UmbracoConfig.For.GridConfig(
|
||||
Logger,
|
||||
ApplicationCache.RuntimeCache,
|
||||
new DirectoryInfo(Server.MapPath(SystemDirectories.AppPlugins)),
|
||||
new DirectoryInfo(Server.MapPath(SystemDirectories.Config)),
|
||||
HttpContext.IsDebuggingEnabled);
|
||||
|
||||
var gridConfig = Current.Config.Grids();
|
||||
return new JsonNetResult { Data = gridConfig.EditorsConfig.Editors, Formatting = Formatting.Indented };
|
||||
}
|
||||
|
||||
|
||||
@@ -314,25 +314,25 @@ namespace Umbraco.Web.Editors
|
||||
{"appPluginsPath", IOHelper.ResolveUrl(SystemDirectories.AppPlugins).TrimEnd('/')},
|
||||
{
|
||||
"imageFileTypes",
|
||||
string.Join(",", UmbracoConfig.For.UmbracoSettings().Content.ImageFileTypes)
|
||||
string.Join(",", Current.Config.Umbraco().Content.ImageFileTypes)
|
||||
},
|
||||
{
|
||||
"disallowedUploadFiles",
|
||||
string.Join(",", UmbracoConfig.For.UmbracoSettings().Content.DisallowedUploadFiles)
|
||||
string.Join(",", Current.Config.Umbraco().Content.DisallowedUploadFiles)
|
||||
},
|
||||
{
|
||||
"allowedUploadFiles",
|
||||
string.Join(",", UmbracoConfig.For.UmbracoSettings().Content.AllowedUploadFiles)
|
||||
string.Join(",", Current.Config.Umbraco().Content.AllowedUploadFiles)
|
||||
},
|
||||
{
|
||||
"maxFileSize",
|
||||
GetMaxRequestLength()
|
||||
},
|
||||
{"keepUserLoggedIn", UmbracoConfig.For.UmbracoSettings().Security.KeepUserLoggedIn},
|
||||
{"usernameIsEmail", UmbracoConfig.For.UmbracoSettings().Security.UsernameIsEmail},
|
||||
{"keepUserLoggedIn", Current.Config.Umbraco().Security.KeepUserLoggedIn},
|
||||
{"usernameIsEmail", Current.Config.Umbraco().Security.UsernameIsEmail},
|
||||
{"cssPath", IOHelper.ResolveUrl(SystemDirectories.Css).TrimEnd('/')},
|
||||
{"allowPasswordReset", UmbracoConfig.For.UmbracoSettings().Security.AllowPasswordReset},
|
||||
{"loginBackgroundImage", UmbracoConfig.For.UmbracoSettings().Content.LoginBackgroundImage},
|
||||
{"allowPasswordReset", Current.Config.Umbraco().Security.AllowPasswordReset},
|
||||
{"loginBackgroundImage", Current.Config.Umbraco().Content.LoginBackgroundImage},
|
||||
{"showUserInvite", EmailSender.CanSendRequiredEmail},
|
||||
{"canSendRequiredEmail", EmailSender.CanSendRequiredEmail},
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace Umbraco.Web.Editors
|
||||
public IDictionary<string, IEnumerable<DataTypeBasic>> GetGroupedPropertyEditors()
|
||||
{
|
||||
var datatypes = new List<DataTypeBasic>();
|
||||
var showDeprecatedPropertyEditors = UmbracoConfig.For.UmbracoSettings().Content.ShowDeprecatedPropertyEditors;
|
||||
var showDeprecatedPropertyEditors = Current.Config.Umbraco().Content.ShowDeprecatedPropertyEditors;
|
||||
|
||||
var propertyEditors = Current.PropertyEditors
|
||||
.Where(x=>x.IsDeprecated == false || showDeprecatedPropertyEditors);
|
||||
|
||||
@@ -23,6 +23,7 @@ using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
using System.Linq;
|
||||
using System.Web.Http.Controllers;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
using Umbraco.Core.Configuration;
|
||||
@@ -426,7 +427,7 @@ namespace Umbraco.Web.Editors
|
||||
var toMove = ValidateMoveOrCopy(move);
|
||||
var destinationParentID = move.ParentId;
|
||||
var sourceParentID = toMove.ParentId;
|
||||
|
||||
|
||||
var moveResult = Services.MediaService.Move(toMove, move.ParentId);
|
||||
|
||||
if (sourceParentID == destinationParentID)
|
||||
@@ -543,7 +544,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
return display;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Empties the recycle bin
|
||||
/// </summary>
|
||||
@@ -596,11 +597,11 @@ namespace Umbraco.Web.Editors
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public MediaItemDisplay PostAddFolder(PostedFolder folder)
|
||||
{
|
||||
var intParentId = GetParentIdAsInt(folder.ParentId, validatePermissions:true);
|
||||
|
||||
|
||||
var mediaService = Services.MediaService;
|
||||
|
||||
var f = mediaService.CreateMedia(folder.Name, intParentId, Constants.Conventions.MediaTypes.Folder);
|
||||
@@ -640,10 +641,10 @@ namespace Umbraco.Web.Editors
|
||||
//get the string json from the request
|
||||
string currentFolderId = result.FormData["currentFolder"];
|
||||
int parentId = GetParentIdAsInt(currentFolderId, validatePermissions: true);
|
||||
|
||||
|
||||
var tempFiles = new PostedFiles();
|
||||
var mediaService = Services.MediaService;
|
||||
|
||||
|
||||
//in case we pass a path with a folder in it, we will create it and upload media to it.
|
||||
if (result.FormData.ContainsKey("path"))
|
||||
{
|
||||
@@ -701,13 +702,13 @@ namespace Umbraco.Web.Editors
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
|
||||
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.IsFileAllowedForUpload(ext))
|
||||
if (Current.Config.Umbraco().Content.IsFileAllowedForUpload(ext))
|
||||
{
|
||||
var mediaType = Constants.Conventions.MediaTypes.File;
|
||||
|
||||
if (result.FormData["contentTypeAlias"] == Constants.Conventions.MediaTypes.AutoSelect)
|
||||
{
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.ImageFileTypes.Contains(ext))
|
||||
if (Current.Config.Umbraco().Content.ImageFileTypes.Contains(ext))
|
||||
{
|
||||
mediaType = Constants.Conventions.MediaTypes.Image;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.WebApi;
|
||||
using File = System.IO.File;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -33,7 +34,7 @@ namespace Umbraco.Web.Editors
|
||||
[HttpGet]
|
||||
public IHttpActionResult GetEnableState()
|
||||
{
|
||||
var enabled = UmbracoConfig.For.UmbracoSettings().WebRouting.DisableRedirectUrlTracking == false;
|
||||
var enabled = Current.Config.Umbraco().WebRouting.DisableRedirectUrlTracking == false;
|
||||
var userIsAdmin = Umbraco.UmbracoContext.Security.CurrentUser.IsAdmin();
|
||||
return Ok(new { enabled, userIsAdmin });
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Web.Models;
|
||||
@@ -25,7 +26,7 @@ namespace Umbraco.Web.Editors
|
||||
{
|
||||
var result = new List<BackOfficeTourFile>();
|
||||
|
||||
if (UmbracoConfig.For.UmbracoSettings().BackOffice.Tours.EnableTours == false)
|
||||
if (Current.Config.Umbraco().BackOffice.Tours.EnableTours == false)
|
||||
return result;
|
||||
|
||||
//get all filters that will be applied to all tour aliases
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models;
|
||||
@@ -58,9 +59,9 @@ namespace Umbraco.Web.Editors
|
||||
var cookie = new CookieHeaderValue("UMB_UPDCHK", "1")
|
||||
{
|
||||
Path = "/",
|
||||
Expires = DateTimeOffset.Now.AddDays(UmbracoConfig.For.GlobalSettings().VersionCheckPeriod),
|
||||
Expires = DateTimeOffset.Now.AddDays(Current.Config.Global().VersionCheckPeriod),
|
||||
HttpOnly = true,
|
||||
Secure = UmbracoConfig.For.GlobalSettings().UseHttps
|
||||
Secure = Current.Config.Global().UseHttps
|
||||
};
|
||||
context.Response.Headers.AddCookies(new[] { cookie });
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Umbraco.Web.Editors
|
||||
var safeFileName = fileName.ToSafeFileName();
|
||||
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
|
||||
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.DisallowedUploadFiles.Contains(ext) == false)
|
||||
if (Current.Config.Umbraco().Content.DisallowedUploadFiles.Contains(ext) == false)
|
||||
{
|
||||
//generate a path of known data, we don't want this path to be guessable
|
||||
user.Avatar = "UserAvatars/" + (user.Id + safeFileName).ToSHA1() + "." + ext;
|
||||
@@ -195,7 +195,7 @@ namespace Umbraco.Web.Editors
|
||||
// so to do that here, we'll need to check if this current user is an admin and if not we should exclude all user who are
|
||||
// also admins
|
||||
|
||||
var hideDisabledUsers = UmbracoConfig.For.UmbracoSettings().Security.HideDisabledUsersInBackoffice;
|
||||
var hideDisabledUsers = Current.Config.Umbraco().Security.HideDisabledUsersInBackoffice;
|
||||
var excludeUserGroups = new string[0];
|
||||
var isAdmin = Security.CurrentUser.IsAdmin();
|
||||
if (isAdmin == false)
|
||||
@@ -253,7 +253,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
|
||||
}
|
||||
|
||||
if (UmbracoConfig.For.UmbracoSettings().Security.UsernameIsEmail)
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail)
|
||||
{
|
||||
//ensure they are the same if we're using it
|
||||
userSave.Username = userSave.Email;
|
||||
@@ -345,7 +345,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
|
||||
IUser user;
|
||||
if (UmbracoConfig.For.UmbracoSettings().Security.UsernameIsEmail)
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail)
|
||||
{
|
||||
//ensure it's the same
|
||||
userSave.Username = userSave.Email;
|
||||
@@ -419,7 +419,7 @@ namespace Umbraco.Web.Editors
|
||||
if (user != null && (extraCheck == null || extraCheck(user)))
|
||||
{
|
||||
ModelState.AddModelError(
|
||||
UmbracoConfig.For.UmbracoSettings().Security.UsernameIsEmail ? "Email" : "Username",
|
||||
Current.Config.Umbraco().Security.UsernameIsEmail ? "Email" : "Username",
|
||||
"A user with the username already exists");
|
||||
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
|
||||
}
|
||||
@@ -539,7 +539,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
// if the found user has his email for username, we want to keep this synced when changing the email.
|
||||
// we have already cross-checked above that the email isn't colliding with anything, so we can safely assign it here.
|
||||
if (UmbracoConfig.For.UmbracoSettings().Security.UsernameIsEmail && found.Username == found.Email && userSave.Username != userSave.Email)
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail && found.Username == found.Email && userSave.Username != userSave.Email)
|
||||
{
|
||||
userSave.Username = userSave.Email;
|
||||
}
|
||||
@@ -552,7 +552,7 @@ namespace Umbraco.Web.Editors
|
||||
var passwordChangeResult = await passwordChanger.ChangePasswordWithIdentityAsync(Security.CurrentUser, found, userSave.ChangePassword, UserManager);
|
||||
if (passwordChangeResult.Success)
|
||||
{
|
||||
//need to re-get the user
|
||||
//need to re-get the user
|
||||
found = Services.UserService.GetUserById(intId.Result);
|
||||
}
|
||||
else
|
||||
@@ -712,7 +712,7 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
var userName = user.Name;
|
||||
Services.UserService.Delete(user, true);
|
||||
|
||||
|
||||
return Request.CreateNotificationSuccessResponse(
|
||||
Services.TextService.Localize("speechBubbles/deleteUserSuccess", new[] { userName }));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
@@ -27,7 +28,7 @@ namespace Umbraco.Web.HealthCheck
|
||||
_checks = checks ?? throw new ArgumentNullException(nameof(checks));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
|
||||
var healthCheckConfig = Current.Config.HealthChecks();
|
||||
_disabledCheckIds = healthCheckConfig.DisabledChecks
|
||||
.Select(x => x.Id)
|
||||
.ToList();
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net.Mail;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -69,7 +70,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
|
||||
|
||||
private MailMessage CreateMailMessage(string subject, string message)
|
||||
{
|
||||
var to = UmbracoConfig.For.UmbracoSettings().Content.NotificationEmailAddress;
|
||||
var to = Current.Config.Umbraco().Content.NotificationEmailAddress;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(subject))
|
||||
subject = "Umbraco Health Check Status";
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
|
||||
@@ -19,7 +20,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
|
||||
return;
|
||||
}
|
||||
|
||||
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
|
||||
var healthCheckConfig = Current.Config.HealthChecks();
|
||||
var notificationMethods = healthCheckConfig.NotificationSettings.NotificationMethods;
|
||||
var notificationMethod = notificationMethods[attribute.Alias];
|
||||
if (notificationMethod == null)
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Umbraco.Web
|
||||
if (UmbracoContext.Current.InPreviewMode)
|
||||
{
|
||||
var htmlBadge =
|
||||
String.Format(UmbracoConfig.For.UmbracoSettings().Content.PreviewBadge,
|
||||
String.Format(Current.Config.Umbraco().Content.PreviewBadge,
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||
UmbracoContext.Current.HttpContext.Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path));
|
||||
return new MvcHtmlString(htmlBadge);
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Web;
|
||||
using System.Web.Security;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Migrations.Install;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -82,7 +83,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
admin.Username = user.Email.Trim();
|
||||
|
||||
_userService.Save(admin);
|
||||
|
||||
|
||||
if (user.SubscribeToNewsLetter)
|
||||
{
|
||||
if (_httpClient == null)
|
||||
@@ -144,7 +145,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
// In this one case when it's a brand new install and nothing has been configured, make sure the
|
||||
// back office cookie is cleared so there's no old cookies lying around causing problems
|
||||
_http.ExpireCookie(UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName);
|
||||
_http.ExpireCookie(Current.Config.Umbraco().Security.AuthCookieName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace Umbraco.Web.Macros
|
||||
Alias = macro.Alias,
|
||||
MacroSource = macro.MacroSource,
|
||||
Exception = e,
|
||||
Behaviour = UmbracoConfig.For.UmbracoSettings().Content.MacroErrorBehaviour
|
||||
Behaviour = Current.Config.Umbraco().Content.MacroErrorBehaviour
|
||||
};
|
||||
|
||||
OnError(macroErrorEventArgs);
|
||||
@@ -604,7 +604,7 @@ namespace Umbraco.Web.Macros
|
||||
querystring += $"&umb_{ide.Key}={HttpContext.Current.Server.UrlEncode((ide.Value ?? String.Empty).ToString())}";
|
||||
|
||||
// create a new 'HttpWebRequest' object to the mentioned URL.
|
||||
var useSsl = UmbracoConfig.For.GlobalSettings().UseHttps;
|
||||
var useSsl = Current.Config.Global().UseHttps;
|
||||
var protocol = useSsl ? "https" : "http";
|
||||
var currentRequest = HttpContext.Current.Request;
|
||||
var serverVars = currentRequest.ServerVariables;
|
||||
@@ -619,7 +619,7 @@ namespace Umbraco.Web.Macros
|
||||
// propagate the user's context
|
||||
// TODO: this is the worst thing ever.
|
||||
// also will not work if people decide to put their own custom auth system in place.
|
||||
var inCookie = currentRequest.Cookies[UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName];
|
||||
var inCookie = currentRequest.Cookies[Current.Config.Umbraco().Security.AuthCookieName];
|
||||
if (inCookie == null) throw new NullReferenceException("No auth cookie found");
|
||||
var cookie = new Cookie(inCookie.Name, inCookie.Value, inCookie.Path, serverVars["SERVER_NAME"]);
|
||||
myHttpWebRequest.CookieContainer = new CookieContainer();
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models.Validation;
|
||||
@@ -75,7 +76,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
return IconIsClass
|
||||
? string.Empty
|
||||
: string.Format("{0}images/umbraco/{1}", UmbracoConfig.For.GlobalSettings().Path.EnsureEndsWith("/"), Icon);
|
||||
: string.Format("{0}images/umbraco/{1}", Current.Config.Global().Path.EnsureEndsWith("/"), Icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
@@ -33,7 +34,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
if (UserGroups.Any() == false)
|
||||
yield return new ValidationResult("A user must be assigned to at least one group", new[] { "UserGroups" });
|
||||
|
||||
if (UmbracoConfig.For.UmbracoSettings().Security.UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
|
||||
if (Current.Config.Umbraco().Security.UsernameIsEmail == false && Username.IsNullOrWhiteSpace())
|
||||
yield return new ValidationResult("A username cannot be empty", new[] { "Username" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
public DataTypeMapperProfile(PropertyEditorCollection propertyEditors, ILogger logger)
|
||||
{
|
||||
// create, capture, cache
|
||||
var availablePropertyEditorsResolver = new AvailablePropertyEditorsResolver(UmbracoConfig.For.UmbracoSettings().Content);
|
||||
var availablePropertyEditorsResolver = new AvailablePropertyEditorsResolver(Current.Config.Umbraco().Content);
|
||||
var configurationDisplayResolver = new DataTypeConfigurationFieldDisplayResolver(logger);
|
||||
var databaseTypeResolver = new DatabaseTypeResolver();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -52,7 +53,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dest => dest.Tabs, opt => opt.ResolveUsing(tabsAndPropertiesResolver))
|
||||
.ForMember(dest => dest.AdditionalData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ContentType, opt => opt.ResolveUsing(mediaTypeBasicResolver))
|
||||
.ForMember(dest => dest.MediaLink, opt => opt.ResolveUsing(content => string.Join(",", content.GetUrls(UmbracoConfig.For.UmbracoSettings().Content, logger))))
|
||||
.ForMember(dest => dest.MediaLink, opt => opt.ResolveUsing(content => string.Join(",", content.GetUrls(Current.Config.Umbraco().Content, logger))))
|
||||
.ForMember(dest => dest.ContentApps, opt => opt.ResolveUsing(mediaAppResolver))
|
||||
.ForMember(dest => dest.VariesByCulture, opt => opt.MapFrom(src => src.ContentType.VariesByCulture()));
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Umbraco.Core.IO;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -111,7 +112,7 @@ namespace Umbraco.Web.Models.Trees
|
||||
return IOHelper.ResolveUrl("~" + Icon.TrimStart('~'));
|
||||
|
||||
//legacy icon path
|
||||
return string.Format("{0}images/umbraco/{1}", UmbracoConfig.For.GlobalSettings().Path.EnsureEndsWith("/"), Icon);
|
||||
return string.Format("{0}images/umbraco/{1}", Current.Config.Global().Path.EnsureEndsWith("/"), Icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Umbraco.Web.Mvc
|
||||
{
|
||||
if (redirectToUmbracoLogin)
|
||||
{
|
||||
_redirectUrl = UmbracoConfig.For.GlobalSettings().Path.EnsureStartsWith("~");
|
||||
_redirectUrl = Current.Config.Global().Path.EnsureStartsWith("~");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Umbraco.Web.Mvc
|
||||
{
|
||||
filterContext.Result = (ActionResult)new HttpUnauthorizedResult("You must login to view this resource.");
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Web.Mvc;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using GlobalSettings = Umbraco.Core.Configuration.GlobalSettings;
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace Umbraco.Web.Mvc
|
||||
protected override void HandleNonHttpsRequest(AuthorizationContext filterContext)
|
||||
{
|
||||
// If umbracoUseSSL is set, let base method handle redirect. Otherwise, we don't care.
|
||||
if (UmbracoConfig.For.GlobalSettings().UseHttps)
|
||||
if (Current.Config.Global().UseHttps)
|
||||
{
|
||||
base.HandleNonHttpsRequest(filterContext);
|
||||
}
|
||||
@@ -29,7 +30,7 @@ namespace Umbraco.Web.Mvc
|
||||
public override void OnAuthorization(AuthorizationContext filterContext)
|
||||
{
|
||||
// If umbracoSSL is set, let base method handle checking for HTTPS. Otherwise, we don't care.
|
||||
if (UmbracoConfig.For.GlobalSettings().UseHttps)
|
||||
if (Current.Config.Global().UseHttps)
|
||||
{
|
||||
base.OnAuthorization(filterContext);
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Umbraco.Web.Mvc
|
||||
{
|
||||
// creating previewBadge markup
|
||||
markupToInject =
|
||||
string.Format(UmbracoConfig.For.UmbracoSettings().Content.PreviewBadge,
|
||||
string.Format(Current.Config.Umbraco().Content.PreviewBadge,
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||
Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
if (fileName.IndexOf('.') <= 0) return false;
|
||||
var extension = Path.GetExtension(fileName).TrimStart(".");
|
||||
return UmbracoConfig.For.UmbracoSettings().Content.IsFileAllowedForUpload(extension);
|
||||
return Current.Config.Umbraco().Content.IsFileAllowedForUpload(extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_mediaRepository = mediaRepository;
|
||||
_memberRepository = memberRepository;
|
||||
_xmlFileEnabled = false;
|
||||
_xmlFileName = IOHelper.MapPath(SystemFiles.GetContentCacheXml(UmbracoConfig.For.GlobalSettings()));
|
||||
_xmlFileName = IOHelper.MapPath(SystemFiles.GetContentCacheXml(Current.Config.Global()));
|
||||
// do not plug events, we may not have what it takes to handle them
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_memberRepository = memberRepository;
|
||||
GetXmlDocument = getXmlDocument ?? throw new ArgumentNullException(nameof(getXmlDocument));
|
||||
_xmlFileEnabled = false;
|
||||
_xmlFileName = IOHelper.MapPath(SystemFiles.GetContentCacheXml(UmbracoConfig.For.GlobalSettings()));
|
||||
_xmlFileName = IOHelper.MapPath(SystemFiles.GetContentCacheXml(Current.Config.Global()));
|
||||
// do not plug events, we may not have what it takes to handle them
|
||||
}
|
||||
|
||||
@@ -253,16 +253,16 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
private readonly bool _xmlFileEnabled = true;
|
||||
|
||||
// whether the disk cache is enabled
|
||||
private bool XmlFileEnabled => _xmlFileEnabled && UmbracoConfig.For.UmbracoSettings().Content.XmlCacheEnabled;
|
||||
private bool XmlFileEnabled => _xmlFileEnabled && Current.Config.Umbraco().Content.XmlCacheEnabled;
|
||||
|
||||
// whether the disk cache is enabled and to update the disk cache when xml changes
|
||||
private bool SyncToXmlFile => XmlFileEnabled && UmbracoConfig.For.UmbracoSettings().Content.ContinouslyUpdateXmlDiskCache;
|
||||
private bool SyncToXmlFile => XmlFileEnabled && Current.Config.Umbraco().Content.ContinouslyUpdateXmlDiskCache;
|
||||
|
||||
// whether the disk cache is enabled and to reload from disk cache if it changes
|
||||
private bool SyncFromXmlFile => XmlFileEnabled && UmbracoConfig.For.UmbracoSettings().Content.XmlContentCheckForDiskChanges;
|
||||
private bool SyncFromXmlFile => XmlFileEnabled && Current.Config.Umbraco().Content.XmlContentCheckForDiskChanges;
|
||||
|
||||
// whether _xml is immutable or not (achieved by cloning before changing anything)
|
||||
private static bool XmlIsImmutable => UmbracoConfig.For.UmbracoSettings().Content.CloneXmlContent;
|
||||
private static bool XmlIsImmutable => Current.Config.Umbraco().Content.CloneXmlContent;
|
||||
|
||||
// whether to keep version of everything (incl. medias & members) in cmsPreviewXml
|
||||
// for audit purposes - false by default, not in umbracoSettings.config
|
||||
@@ -1241,7 +1241,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
|
||||
// the types will be reloaded if/when needed
|
||||
foreach (var payload in payloads)
|
||||
_contentTypeCache.ClearDataType(payload.Id);
|
||||
|
||||
|
||||
foreach (var payload in payloads)
|
||||
Current.Logger.Debug<XmlStore>("Notified {RemovedStatus} for data type {payload.Id}",
|
||||
payload.Removed ? "Removed" : "Refreshed",
|
||||
|
||||
@@ -87,10 +87,10 @@ namespace Umbraco.Web
|
||||
|
||||
public static bool IsAllowedTemplate(this IPublishedContent content, int templateId)
|
||||
{
|
||||
if (UmbracoConfig.For.UmbracoSettings().WebRouting.DisableAlternativeTemplates == true)
|
||||
if (Current.Config.Umbraco().WebRouting.DisableAlternativeTemplates == true)
|
||||
return content.TemplateId == templateId;
|
||||
|
||||
if (content.TemplateId != templateId && UmbracoConfig.For.UmbracoSettings().WebRouting.ValidateAlternativeTemplates == true)
|
||||
if (content.TemplateId != templateId && Current.Config.Umbraco().WebRouting.ValidateAlternativeTemplates == true)
|
||||
{
|
||||
// fixme - perfs? nothing cached here
|
||||
var publishedContentContentType = Current.Services.ContentTypeService.Get(content.ContentType.Id);
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using umbraco;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
@@ -180,7 +181,7 @@ namespace Umbraco.Web.Routing
|
||||
IsInternalRedirectPublishedContent = isInternalRedirect;
|
||||
|
||||
// must restore the template if it's an internal redirect & the config option is set
|
||||
if (isInternalRedirect && UmbracoConfig.For.UmbracoSettings().WebRouting.InternalRedirectPreservesTemplate)
|
||||
if (isInternalRedirect && Current.Config.Umbraco().WebRouting.InternalRedirectPreservesTemplate)
|
||||
{
|
||||
// restore
|
||||
_template = template;
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace Umbraco.Web.Runtime
|
||||
|
||||
// register published router
|
||||
composition.RegisterUnique<PublishedRouter>();
|
||||
composition.Register(_ => UmbracoConfig.For.UmbracoSettings().WebRouting);
|
||||
composition.Register(_ => Current.Config.Umbraco().WebRouting);
|
||||
|
||||
// register preview SignalR hub
|
||||
composition.RegisterUnique(_ => GlobalHost.ConnectionManager.GetHubContext<PreviewHub>());
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Sync;
|
||||
@@ -54,7 +55,7 @@ namespace Umbraco.Web.Scheduling
|
||||
|
||||
using (_proflog.DebugDuration<KeepAlive>("Health checks executing", "Health checks complete"))
|
||||
{
|
||||
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
|
||||
var healthCheckConfig = Current.Config.HealthChecks();
|
||||
|
||||
// Don't notify for any checks that are disabled, nor for any disabled
|
||||
// just for notifications
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Components;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.HealthChecks;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
@@ -86,7 +87,7 @@ namespace Umbraco.Web.Scheduling
|
||||
LazyInitializer.EnsureInitialized(ref _tasks, ref _started, ref _locker, () =>
|
||||
{
|
||||
_logger.Debug<SchedulerComponent>("Initializing the scheduler");
|
||||
var settings = UmbracoConfig.For.UmbracoSettings();
|
||||
var settings = Current.Config.Umbraco();
|
||||
|
||||
var tasks = new List<IBackgroundTask>();
|
||||
|
||||
@@ -95,7 +96,7 @@ namespace Umbraco.Web.Scheduling
|
||||
tasks.Add(RegisterTaskRunner(settings));
|
||||
tasks.Add(RegisterLogScrubber(settings));
|
||||
|
||||
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
|
||||
var healthCheckConfig = Current.Config.HealthChecks();
|
||||
if (healthCheckConfig.NotificationSettings.Enabled)
|
||||
tasks.Add(RegisterHealthCheckNotifier(healthCheckConfig, _healthChecks, _notifications, _logger, _proflog));
|
||||
|
||||
|
||||
@@ -211,8 +211,8 @@ namespace Umbraco.Web.Security
|
||||
//This is a custom middleware, we need to return the user's remaining logged in seconds
|
||||
app.Use<GetUserSecondsMiddleWare>(
|
||||
cookieAuthOptions,
|
||||
UmbracoConfig.For.GlobalSettings(),
|
||||
UmbracoConfig.For.UmbracoSettings().Security,
|
||||
Current.Config.Global(),
|
||||
Current.Config.Umbraco().Security,
|
||||
app.CreateLogger<GetUserSecondsMiddleWare>());
|
||||
|
||||
//This is required so that we can read the auth ticket format outside of this pipeline
|
||||
@@ -316,7 +316,7 @@ namespace Umbraco.Web.Security
|
||||
CookiePath = "/",
|
||||
CookieSecure = globalSettings.UseHttps ? CookieSecureOption.Always : CookieSecureOption.SameAsRequest,
|
||||
CookieHttpOnly = true,
|
||||
CookieDomain = UmbracoConfig.For.UmbracoSettings().Security.AuthCookieDomain
|
||||
CookieDomain = Current.Config.Umbraco().Security.AuthCookieDomain
|
||||
}, stage);
|
||||
|
||||
return app;
|
||||
@@ -362,7 +362,7 @@ namespace Umbraco.Web.Security
|
||||
if (runtimeState.Level != RuntimeLevel.Run) return app;
|
||||
|
||||
var authOptions = app.CreateUmbracoCookieAuthOptions(umbracoContextAccessor, globalSettings, runtimeState, securitySettings);
|
||||
app.Use(typeof(PreviewAuthenticationMiddleware), authOptions, UmbracoConfig.For.GlobalSettings());
|
||||
app.Use(typeof(PreviewAuthenticationMiddleware), authOptions, Current.Config.Global());
|
||||
|
||||
// This middleware must execute at least on PostAuthentication, by default it is on Authorize
|
||||
// The middleware needs to execute after the RoleManagerModule executes which is during PostAuthenticate,
|
||||
@@ -391,7 +391,7 @@ namespace Umbraco.Web.Security
|
||||
/// <param name="explicitPaths"></param>
|
||||
/// <returns></returns>
|
||||
public static UmbracoBackOfficeCookieAuthOptions CreateUmbracoCookieAuthOptions(this IAppBuilder app,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IUmbracoContextAccessor umbracoContextAccessor,
|
||||
IGlobalSettings globalSettings, IRuntimeState runtimeState, ISecuritySection securitySettings, string[] explicitPaths = null)
|
||||
{
|
||||
//this is how aspnet wires up the default AuthenticationTicket protector so we'll use the same code
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace Umbraco.Web.Security
|
||||
public static void UmbracoLogout(this HttpContextBase http)
|
||||
{
|
||||
if (http == null) throw new ArgumentNullException("http");
|
||||
Logout(http, UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName);
|
||||
Logout(http, Current.Config.Umbraco().Security.AuthCookieName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -181,7 +181,7 @@ namespace Umbraco.Web.Security
|
||||
http.Items[Constants.Security.ForceReAuthFlag] = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// returns the number of seconds the user has until their auth session times out
|
||||
/// </summary>
|
||||
@@ -193,7 +193,7 @@ namespace Umbraco.Web.Security
|
||||
var ticket = http.GetUmbracoAuthTicket();
|
||||
return ticket.GetRemainingAuthSeconds();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// returns the number of seconds the user has until their auth session times out
|
||||
/// </summary>
|
||||
@@ -215,7 +215,7 @@ namespace Umbraco.Web.Security
|
||||
public static AuthenticationTicket GetUmbracoAuthTicket(this HttpContextBase http)
|
||||
{
|
||||
if (http == null) throw new ArgumentNullException(nameof(http));
|
||||
return GetAuthTicket(http, UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName);
|
||||
return GetAuthTicket(http, Current.Config.Umbraco().Security.AuthCookieName);
|
||||
}
|
||||
|
||||
internal static AuthenticationTicket GetUmbracoAuthTicket(this HttpContext http)
|
||||
@@ -227,7 +227,7 @@ namespace Umbraco.Web.Security
|
||||
public static AuthenticationTicket GetUmbracoAuthTicket(this IOwinContext ctx)
|
||||
{
|
||||
if (ctx == null) throw new ArgumentNullException(nameof(ctx));
|
||||
return GetAuthTicket(ctx, UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName);
|
||||
return GetAuthTicket(ctx, Current.Config.Umbraco().Security.AuthCookieName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -342,7 +342,7 @@ namespace Umbraco.Web.Security
|
||||
return null;
|
||||
}
|
||||
//get the ticket
|
||||
|
||||
|
||||
return secureDataFormat.Unprotect(formsCookie);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Web.Security
|
||||
private readonly IUserService _userService;
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
|
||||
|
||||
public BackOfficeCookieAuthenticationProvider(IUserService userService, IRuntimeState runtimeState, IGlobalSettings globalSettings)
|
||||
{
|
||||
_userService = userService;
|
||||
@@ -67,7 +67,7 @@ namespace Umbraco.Web.Security
|
||||
Expires = DateTime.Now.AddYears(-1),
|
||||
Path = "/"
|
||||
});
|
||||
context.Response.Cookies.Append(UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName, "", new CookieOptions
|
||||
context.Response.Cookies.Append(Current.Config.Umbraco().Security.AuthCookieName, "", new CookieOptions
|
||||
{
|
||||
Expires = DateTime.Now.AddYears(-1),
|
||||
Path = "/"
|
||||
@@ -111,8 +111,8 @@ namespace Umbraco.Web.Security
|
||||
await SessionIdValidator.ValidateSessionAsync(TimeSpan.FromMinutes(1), context, _globalSettings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Microsoft.AspNet.Identity.Owin;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Identity;
|
||||
|
||||
@@ -23,7 +24,7 @@ namespace Umbraco.Web.Security
|
||||
{
|
||||
_defaultUserGroups = defaultUserGroups ?? new[] { "editor" };
|
||||
_autoLinkExternalAccount = autoLinkExternalAccount;
|
||||
_defaultCulture = defaultCulture ?? UmbracoConfig.For.GlobalSettings().DefaultUILanguage;
|
||||
_defaultCulture = defaultCulture ?? Current.Config.Global().DefaultUILanguage;
|
||||
}
|
||||
|
||||
private readonly string[] _defaultUserGroups;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Umbraco.Web.Security.Providers
|
||||
|
||||
public override string ProviderName
|
||||
{
|
||||
get { return UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider; }
|
||||
get { return Current.Config.Umbraco().Providers.DefaultBackOfficeUserProvider; }
|
||||
}
|
||||
|
||||
protected override MembershipUser ConvertToMembershipUser(IUser entity)
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Umbraco.Web.Templates
|
||||
//set the doc that was found by id
|
||||
contentRequest.PublishedContent = doc;
|
||||
//set the template, either based on the AltTemplate found or the standard template of the doc
|
||||
contentRequest.TemplateModel = UmbracoConfig.For.UmbracoSettings().WebRouting.DisableAlternativeTemplates || AltTemplate.HasValue == false
|
||||
contentRequest.TemplateModel = Current.Config.Umbraco().WebRouting.DisableAlternativeTemplates || AltTemplate.HasValue == false
|
||||
? FileService.GetTemplate(doc.TemplateId)
|
||||
: FileService.GetTemplate(AltTemplate.Value);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Umbraco.Web.Templates
|
||||
/// </remarks>
|
||||
public static string ResolveUrlsFromTextString(string text)
|
||||
{
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.ResolveUrlsFromTextString == false) return text;
|
||||
if (Current.Config.Umbraco().Content.ResolveUrlsFromTextString == false) return text;
|
||||
|
||||
using (var timer = Current.ProfilingLogger.DebugDuration(typeof(IOHelper), "ResolveUrlsFromTextString starting", "ResolveUrlsFromTextString complete"))
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -73,7 +74,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
var enableInheritedDocumentTypes = UmbracoConfig.For.UmbracoSettings().Content.EnableInheritedDocumentTypes;
|
||||
var enableInheritedDocumentTypes = Current.Config.Umbraco().Content.EnableInheritedDocumentTypes;
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
case ActionDelete actionDelete:
|
||||
return Attempt.Succeed(
|
||||
UmbracoConfig.For.GlobalSettings().Path.EnsureEndsWith('/') + "views/common/dialogs/legacydelete.html");
|
||||
Current.Config.Global().Path.EnsureEndsWith('/') + "views/common/dialogs/legacydelete.html");
|
||||
}
|
||||
|
||||
return Attempt<string>.Fail();
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
@@ -66,7 +67,7 @@ namespace Umbraco.Web.Trees
|
||||
{
|
||||
var menu = new MenuItemCollection();
|
||||
|
||||
var enableInheritedMediaTypes = UmbracoConfig.For.UmbracoSettings().Content.EnableInheritedMediaTypes;
|
||||
var enableInheritedMediaTypes = Current.Config.Umbraco().Content.EnableInheritedMediaTypes;
|
||||
|
||||
if (id == Constants.System.Root.ToInvariantString())
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Umbraco.Web.UI.Pages
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
if (Request.IsSecureConnection || UmbracoConfig.For.GlobalSettings().UseHttps == false) return;
|
||||
if (Request.IsSecureConnection || Current.Config.Global().UseHttps == false) return;
|
||||
|
||||
var serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);
|
||||
Response.Redirect($"https://{serverName}{Request.FilePath}");
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Web.UI.Pages
|
||||
//If this is not a back office request, then the module won't have authenticated it, in this case we
|
||||
// need to do the auth manually and since this is an UmbracoEnsuredPage, this is the anticipated behavior
|
||||
// TODO: When we implement Identity, this process might not work anymore, will be an interesting challenge
|
||||
if (Context.Request.Url.IsBackOfficeRequest(HttpRuntime.AppDomainAppVirtualPath, UmbracoConfig.For.GlobalSettings()) == false)
|
||||
if (Context.Request.Url.IsBackOfficeRequest(HttpRuntime.AppDomainAppVirtualPath, Current.Config.Global()) == false)
|
||||
{
|
||||
var http = new HttpContextWrapper(Context);
|
||||
var ticket = http.GetUmbracoAuthTicket();
|
||||
|
||||
@@ -111,10 +111,10 @@ namespace Umbraco.Web
|
||||
Composing.Current.UmbracoContextAccessor,
|
||||
httpContext,
|
||||
Composing.Current.PublishedSnapshotService,
|
||||
new WebSecurity(httpContext, Composing.Current.Services.UserService, UmbracoConfig.For.GlobalSettings()),
|
||||
UmbracoConfig.For.UmbracoSettings(),
|
||||
new WebSecurity(httpContext, Composing.Current.Services.UserService, Composing.Current.Config.Global()),
|
||||
Composing.Current.Config.Umbraco(),
|
||||
Composing.Current.UrlProviders,
|
||||
UmbracoConfig.For.GlobalSettings(),
|
||||
Composing.Current.Config.Global(),
|
||||
Composing.Current.Factory.GetInstance<IVariationContextAccessor>(),
|
||||
true);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Umbraco.Web
|
||||
public class UmbracoDefaultOwinStartup
|
||||
{
|
||||
protected IUmbracoContextAccessor UmbracoContextAccessor => Current.UmbracoContextAccessor;
|
||||
protected IGlobalSettings GlobalSettings => UmbracoConfig.For.GlobalSettings();
|
||||
protected IUmbracoSettingsSection UmbracoSettings => UmbracoConfig.For.UmbracoSettings();
|
||||
protected IGlobalSettings GlobalSettings => Current.Config.Global();
|
||||
protected IUmbracoSettingsSection UmbracoSettings => Current.Config.Umbraco();
|
||||
protected IRuntimeState RuntimeState => Core.Composing.Current.RuntimeState;
|
||||
protected ServiceContext Services => Current.Services;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Web
|
||||
protected virtual void ConfigureMiddleware(IAppBuilder app)
|
||||
{
|
||||
|
||||
// Configure OWIN for authentication.
|
||||
// Configure OWIN for authentication.
|
||||
ConfigureUmbracoAuthentication(app);
|
||||
|
||||
app
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Umbraco.Web
|
||||
httpContext,
|
||||
_publishedSnapshotService,
|
||||
new WebSecurity(httpContext, _userService, _globalSettings),
|
||||
UmbracoConfig.For.UmbracoSettings(),
|
||||
Current.Config.Umbraco(),
|
||||
_urlProviders,
|
||||
_globalSettings,
|
||||
_variationContextAccessor,
|
||||
@@ -270,7 +270,7 @@ namespace Umbraco.Web
|
||||
ReportRuntime(level, "Umbraco is booting.");
|
||||
|
||||
// let requests pile up and wait for 10s then show the splash anyway
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.EnableSplashWhileLoading == false
|
||||
if (Current.Config.Umbraco().Content.EnableSplashWhileLoading == false
|
||||
&& ((RuntimeState) _runtime).WaitForRunLevel(TimeSpan.FromSeconds(10))) return true;
|
||||
|
||||
// redirect to booting page
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Umbraco.Web
|
||||
else if (pcr.Is404)
|
||||
{
|
||||
response.StatusCode = 404;
|
||||
response.TrySkipIisCustomErrors = UmbracoConfig.For.UmbracoSettings().WebRouting.TrySkipIisCustomErrors;
|
||||
response.TrySkipIisCustomErrors = Current.Config.Umbraco().WebRouting.TrySkipIisCustomErrors;
|
||||
|
||||
if (response.TrySkipIisCustomErrors == false)
|
||||
logger.Warn<UmbracoModule>("Status code is 404 yet TrySkipIisCustomErrors is false - IIS will take over.");
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Umbraco.Web
|
||||
Logger = Current.Logger;
|
||||
ProfilingLogger = Current.ProfilingLogger;
|
||||
Services = Current.Services;
|
||||
GlobalSettings = UmbracoConfig.For.GlobalSettings();
|
||||
GlobalSettings = Current.Config.Global();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
() => user.Username != identity.Username,
|
||||
() =>
|
||||
{
|
||||
var culture = UserExtensions.GetUserCulture(user, Current.Services.TextService, UmbracoConfig.For.GlobalSettings());
|
||||
var culture = UserExtensions.GetUserCulture(user, Current.Services.TextService, Current.Config.Global());
|
||||
return culture != null && culture.ToString() != identity.Culture;
|
||||
},
|
||||
() => user.AllowedSections.UnsortedSequenceEqual(identity.AllowedApplications) == false,
|
||||
@@ -111,10 +111,10 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
if (owinCtx)
|
||||
{
|
||||
var signInManager = owinCtx.Result.GetBackOfficeSignInManager();
|
||||
|
||||
|
||||
var backOfficeIdentityUser = Mapper.Map<BackOfficeIdentityUser>(user);
|
||||
await signInManager.SignInAsync(backOfficeIdentityUser, isPersistent: true, rememberBrowser: false);
|
||||
|
||||
|
||||
//ensure the remainder of the request has the correct principal set
|
||||
actionContext.Request.SetPrincipalForRequest(owinCtx.Result.Request.User);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Web.WebApi.Filters
|
||||
@@ -43,14 +44,14 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
Path = "/",
|
||||
//must be js readable
|
||||
HttpOnly = false,
|
||||
Secure = UmbracoConfig.For.GlobalSettings().UseHttps
|
||||
Secure = Current.Config.Global().UseHttps
|
||||
};
|
||||
|
||||
var validationCookie = new CookieHeaderValue(AngularAntiForgeryHelper.CsrfValidationCookieName, cookieToken)
|
||||
{
|
||||
Path = "/",
|
||||
HttpOnly = true,
|
||||
Secure = UmbracoConfig.For.GlobalSettings().UseHttps
|
||||
Secure = Current.Config.Global().UseHttps
|
||||
};
|
||||
|
||||
context.Response.Headers.AddCookies(new[] { angularCookie, validationCookie });
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Web.WebApi.Filters
|
||||
@@ -23,7 +24,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
public override void OnAuthorization(HttpActionContext actionContext)
|
||||
{
|
||||
var request = actionContext.Request;
|
||||
if (UmbracoConfig.For.GlobalSettings().UseHttps && request.RequestUri.Scheme != Uri.UriSchemeHttps)
|
||||
if (Current.Config.Global().UseHttps && request.RequestUri.Scheme != Uri.UriSchemeHttps)
|
||||
{
|
||||
HttpResponseMessage response;
|
||||
var uri = new UriBuilder(request.RequestUri)
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace umbraco
|
||||
if (pos > -1)
|
||||
{
|
||||
string htmlBadge =
|
||||
string.Format(UmbracoConfig.For.UmbracoSettings().Content.PreviewBadge,
|
||||
string.Format(Current.Config.Umbraco().Content.PreviewBadge,
|
||||
IOHelper.ResolveUrl(SystemDirectories.Umbraco),
|
||||
Server.UrlEncode(UmbracoContext.Current.HttpContext.Request.Path));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user