https://github.com/umbraco/Umbraco-CMS/issues/10650 - Added redirect in backoffice controller if you are not in run state.

This commit is contained in:
Bjarke Berg
2021-09-09 15:37:13 +02:00
parent dc0994a429
commit 41aabd2515

View File

@@ -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<IActionResult> 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