Merge pull request from GHSA-h8wc-r4jh-mg7m
* Don't login after install * Fail the install if database is not created --------- Co-authored-by: Zeegaan <nge@umbraco.dk> Co-authored-by: Nikolaj <nikolajlauridsen@protonmail.ch>
This commit is contained in:
committed by
nikolajlauridsen
parent
2a601ae0d0
commit
20a4e475c8
@@ -212,7 +212,7 @@ public class RuntimeState : IRuntimeState
|
|||||||
if (_globalSettings.Value.InstallMissingDatabase || _databaseProviderMetadata.CanForceCreateDatabase(_databaseFactory))
|
if (_globalSettings.Value.InstallMissingDatabase || _databaseProviderMetadata.CanForceCreateDatabase(_databaseFactory))
|
||||||
{
|
{
|
||||||
// ok to install on a configured but missing database
|
// ok to install on a configured but missing database
|
||||||
Level = RuntimeLevel.Install;
|
Level = RuntimeLevel.BootFailed;
|
||||||
Reason = RuntimeLevelReason.InstallMissingDatabase;
|
Reason = RuntimeLevelReason.InstallMissingDatabase;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Umbraco.Cms.Core;
|
using Umbraco.Cms.Core;
|
||||||
@@ -25,8 +26,6 @@ namespace Umbraco.Cms.Web.BackOffice.Install;
|
|||||||
[Area(Constants.Web.Mvc.InstallArea)]
|
[Area(Constants.Web.Mvc.InstallArea)]
|
||||||
public class InstallApiController : ControllerBase
|
public class InstallApiController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IBackOfficeSignInManager _backOfficeSignInManager;
|
|
||||||
private readonly IBackOfficeUserManager _backOfficeUserManager;
|
|
||||||
private readonly DatabaseBuilder _databaseBuilder;
|
private readonly DatabaseBuilder _databaseBuilder;
|
||||||
private readonly InstallStatusTracker _installStatusTracker;
|
private readonly InstallStatusTracker _installStatusTracker;
|
||||||
private readonly InstallStepCollection _installSteps;
|
private readonly InstallStepCollection _installSteps;
|
||||||
@@ -34,6 +33,7 @@ public class InstallApiController : ControllerBase
|
|||||||
private readonly IProfilingLogger _proflog;
|
private readonly IProfilingLogger _proflog;
|
||||||
private readonly IRuntime _runtime;
|
private readonly IRuntime _runtime;
|
||||||
|
|
||||||
|
[Obsolete("Use the constructor without IBackOfficeUserManager & IBackOfficeSignInManager instead, scheduled for removal in v14")]
|
||||||
public InstallApiController(
|
public InstallApiController(
|
||||||
DatabaseBuilder databaseBuilder,
|
DatabaseBuilder databaseBuilder,
|
||||||
IProfilingLogger proflog,
|
IProfilingLogger proflog,
|
||||||
@@ -44,14 +44,25 @@ public class InstallApiController : ControllerBase
|
|||||||
IRuntime runtime,
|
IRuntime runtime,
|
||||||
IBackOfficeUserManager backOfficeUserManager,
|
IBackOfficeUserManager backOfficeUserManager,
|
||||||
IBackOfficeSignInManager backOfficeSignInManager)
|
IBackOfficeSignInManager backOfficeSignInManager)
|
||||||
|
: this(databaseBuilder, proflog, logger, installHelper, installSteps, installStatusTracker, runtime)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[ActivatorUtilitiesConstructor]
|
||||||
|
public InstallApiController(
|
||||||
|
DatabaseBuilder databaseBuilder,
|
||||||
|
IProfilingLogger proflog,
|
||||||
|
ILogger<InstallApiController> logger,
|
||||||
|
InstallHelper installHelper,
|
||||||
|
InstallStepCollection installSteps,
|
||||||
|
InstallStatusTracker installStatusTracker,
|
||||||
|
IRuntime runtime)
|
||||||
{
|
{
|
||||||
_databaseBuilder = databaseBuilder ?? throw new ArgumentNullException(nameof(databaseBuilder));
|
_databaseBuilder = databaseBuilder ?? throw new ArgumentNullException(nameof(databaseBuilder));
|
||||||
_proflog = proflog ?? throw new ArgumentNullException(nameof(proflog));
|
_proflog = proflog ?? throw new ArgumentNullException(nameof(proflog));
|
||||||
_installSteps = installSteps;
|
_installSteps = installSteps;
|
||||||
_installStatusTracker = installStatusTracker;
|
_installStatusTracker = installStatusTracker;
|
||||||
_runtime = runtime;
|
_runtime = runtime;
|
||||||
_backOfficeUserManager = backOfficeUserManager;
|
|
||||||
_backOfficeSignInManager = backOfficeSignInManager;
|
|
||||||
InstallHelper = installHelper;
|
InstallHelper = installHelper;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
@@ -88,20 +99,8 @@ public class InstallApiController : ControllerBase
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ActionResult> CompleteInstall()
|
public async Task<ActionResult> CompleteInstall()
|
||||||
{
|
{
|
||||||
RuntimeLevel levelBeforeRestart = _runtime.State.Level;
|
|
||||||
|
|
||||||
await _runtime.RestartAsync();
|
await _runtime.RestartAsync();
|
||||||
|
|
||||||
if (levelBeforeRestart == RuntimeLevel.Install)
|
|
||||||
{
|
|
||||||
BackOfficeIdentityUser? identityUser =
|
|
||||||
await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString);
|
|
||||||
if (identityUser is not null)
|
|
||||||
{
|
|
||||||
_backOfficeSignInManager.SignInAsync(identityUser, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user