From 5500f872235bdcaf7832686a31b86b748b755cc3 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Mon, 5 Sep 2022 21:11:17 +0200 Subject: [PATCH] Limit what API does when not in used in Install level (cherry picked from commit 7b00c0d3e9e3da88f7f2b9cc8f88df28851e5d76) --- .../Install/InstallApiController.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs index e5f1c4fc36..02538ea528 100644 --- a/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallApiController.cs @@ -87,11 +87,15 @@ public class InstallApiController : ControllerBase [HttpPost] public async Task CompleteInstall() { + RuntimeLevel levelBeforeRestart = _runtime.State.Level; + await _runtime.RestartAsync(); - BackOfficeIdentityUser identityUser = - await _backOfficeUserManager.FindByIdAsync(Constants.Security.SuperUserIdAsString); - _backOfficeSignInManager.SignInAsync(identityUser, false); + if (levelBeforeRestart == RuntimeLevel.Install) + { + BackOfficeIdentityUser identityUser = await _backOfficeUserManager.FindByIdAsync(Core.Constants.Security.SuperUserIdAsString); + _backOfficeSignInManager.SignInAsync(identityUser, false); + } return NoContent(); }