From 58da7f754b78434623d028180943f87bced383ac Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Mon, 19 Dec 2022 11:52:48 +0100 Subject: [PATCH] Rename fixed extension method to GetUmbracoBackOfficeUrl and obsolete old one --- .../Install/InstallAuthorizeAttribute.cs | 2 +- .../Extensions/LinkGeneratorExtensions.cs | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Install/InstallAuthorizeAttribute.cs b/src/Umbraco.Web.BackOffice/Install/InstallAuthorizeAttribute.cs index 2c6d5102e8..6d58e902d4 100644 --- a/src/Umbraco.Web.BackOffice/Install/InstallAuthorizeAttribute.cs +++ b/src/Umbraco.Web.BackOffice/Install/InstallAuthorizeAttribute.cs @@ -42,7 +42,7 @@ public class InstallAuthorizeAttribute : TypeFilterAttribute // Only authorize when the installer is enabled context.Result = new ForbidResult(new AuthenticationProperties() { - RedirectUri = _linkGenerator.GetBackOfficeUrl(_hostingEnvironment) + RedirectUri = _linkGenerator.GetUmbracoBackOfficeUrl(_hostingEnvironment) }); } else if (_runtimeState.Level == RuntimeLevel.Upgrade && (await context.HttpContext.AuthenticateBackOfficeAsync()).Succeeded == false) diff --git a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs index 70f8d1c2fe..1c589ebe2a 100644 --- a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs @@ -13,25 +13,35 @@ namespace Umbraco.Extensions; public static class LinkGeneratorExtensions { /// - /// Gets the backoffice URL (if the back office is installed). + /// Gets the Umbraco backoffice URL (if Umbraco is installed). /// /// The link generator. /// - /// The backoffice URL. + /// The Umbraco backoffice URL. /// - public static string? GetBackOfficeUrl(this LinkGenerator linkGenerator) + public static string? GetUmbracoBackOfficeUrl(this LinkGenerator linkGenerator) => linkGenerator.GetPathByAction("Default", "BackOffice", new { area = Constants.Web.Mvc.BackOfficeArea }); /// - /// Gets the backoffice URL (if the back office is installed) or application virtual path (in most cases just "/"). + /// Gets the Umbraco backoffice URL (if Umbraco is installed) or application virtual path (in most cases just "/"). /// /// The link generator. /// The hosting environment. /// - /// The backoffice URL. + /// The Umbraco backoffice URL. /// - public static string GetBackOfficeUrl(this LinkGenerator linkGenerator, IHostingEnvironment hostingEnvironment) - => GetBackOfficeUrl(linkGenerator) ?? hostingEnvironment.ApplicationVirtualPath; + public static string GetUmbracoBackOfficeUrl(this LinkGenerator linkGenerator, IHostingEnvironment hostingEnvironment) + => GetUmbracoBackOfficeUrl(linkGenerator) ?? hostingEnvironment.ApplicationVirtualPath; + + /// + /// Return the back office url if the back office is installed + /// + /// + /// This method contained a bug that would result in always returning "/". + /// + [Obsolete("Use the GetUmbracoBackOfficeUrl extension method instead. This method will be removed in Umbraco 13.")] + public static string? GetBackOfficeUrl(this LinkGenerator linkGenerator, IHostingEnvironment hostingEnvironment) + => "/"; /// /// Return the Url for a Web Api service