From 41aabd2515e01f4232bfb516585ce4c5596410d5 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 9 Sep 2021 15:37:13 +0200 Subject: [PATCH] https://github.com/umbraco/Umbraco-CMS/issues/10650 - Added redirect in backoffice controller if you are not in run state. --- .../Controllers/BackOfficeController.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs index 4d3ea289b5..bf7c9bbb12 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Umbraco.Cms.Core; using Umbraco.Cms.Core.Cache; using Umbraco.Cms.Core.Configuration.Grid; using Umbraco.Cms.Core.Configuration.Models; @@ -112,12 +113,17 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers [AllowAnonymous] public async Task Default() { - // TODO: It seems that if you login during an authorize upgrade and the upgrade fails, you can still - // access the back office. This should redirect to the installer in that case? + // Check if we not are in an run state, if so we need to redirect + if (_runtimeState.Level != RuntimeLevel.Run) + { + return Redirect("/"); + } // force authentication to occur since this is not an authorized endpoint var result = await this.AuthenticateBackOfficeAsync(); + + var viewPath = Path.Combine(Constants.SystemDirectories.Umbraco, Constants.Web.Mvc.BackOfficeArea, nameof(Default) + ".cshtml") .Replace("\\", "/"); // convert to forward slashes since it's a virtual path