Introduced an extension method on IHttpContextAccessor that return the HttpContext or throws if null.
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Umbraco.Web.Install
|
||||
{
|
||||
private static HttpClient _httpClient;
|
||||
private readonly DatabaseBuilder _databaseBuilder;
|
||||
private readonly HttpContextBase _httpContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
@@ -29,7 +29,7 @@ namespace Umbraco.Web.Install
|
||||
DatabaseBuilder databaseBuilder,
|
||||
ILogger logger, IGlobalSettings globalSettings, IUmbracoVersion umbracoVersion, IConnectionStrings connectionStrings)
|
||||
{
|
||||
_httpContext = httpContextAccessor.HttpContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_logger = logger;
|
||||
_globalSettings = globalSettings;
|
||||
_umbracoVersion = umbracoVersion;
|
||||
@@ -46,12 +46,13 @@ namespace Umbraco.Web.Install
|
||||
{
|
||||
try
|
||||
{
|
||||
var userAgent = _httpContext.Request.UserAgent;
|
||||
var httpContext = _httpContextAccessor.GetRequiredHttpContext();
|
||||
var userAgent = httpContext.Request.UserAgent;
|
||||
|
||||
// Check for current install Id
|
||||
var installId = Guid.NewGuid();
|
||||
|
||||
var installCookie = _httpContext.Request.GetCookieValue(Constants.Web.InstallerCookieName);
|
||||
var installCookie = httpContext.Request.GetCookieValue(Constants.Web.InstallerCookieName);
|
||||
if (string.IsNullOrEmpty(installCookie) == false)
|
||||
{
|
||||
if (Guid.TryParse(installCookie, out installId))
|
||||
@@ -61,7 +62,7 @@ namespace Umbraco.Web.Install
|
||||
installId = Guid.NewGuid();
|
||||
}
|
||||
}
|
||||
_httpContext.Response.Cookies.Set(new HttpCookie(Constants.Web.InstallerCookieName, "1"));
|
||||
httpContext.Response.Cookies.Set(new HttpCookie(Constants.Web.InstallerCookieName, "1"));
|
||||
|
||||
var dbProvider = string.Empty;
|
||||
if (IsBrandNewInstall == false)
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
throw new InvalidOperationException("Could not find the super user!");
|
||||
}
|
||||
|
||||
var userManager = _httpContextAccessor.HttpContext.GetOwinContext().GetBackOfficeUserManager();
|
||||
var userManager = _httpContextAccessor.GetRequiredHttpContext().GetOwinContext().GetBackOfficeUserManager();
|
||||
var membershipUser = await userManager.FindByIdAsync(Constants.Security.SuperUserId);
|
||||
if (membershipUser == null)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
|
||||
InstallBusinessLogic(packageId);
|
||||
|
||||
UmbracoApplication.Restart(_httContextAccessor.HttpContext);
|
||||
UmbracoApplication.Restart(_httContextAccessor.GetRequiredHttpContext());
|
||||
|
||||
return Task.FromResult<InstallSetupResult>(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user