diff --git a/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts b/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts index 3b5d890065..9435f94a1b 100644 --- a/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts +++ b/src/Umbraco.Web.UI.Client/src/apps/backoffice/components/backoffice-main.element.ts @@ -63,13 +63,13 @@ export class UmbBackofficeMainElement extends UmbLitElement { if (newRoutes.length > 0) { newRoutes.push({ - path: `**`, - component: async () => (await import('@umbraco-cms/backoffice/router')).UmbRouteNotFoundElement, + redirectTo: newRoutes[0].path, + path: ``, }); newRoutes.push({ - redirectTo: newRoutes[0].path, - path: ``, + path: `**`, + component: async () => (await import('@umbraco-cms/backoffice/router')).UmbRouteNotFoundElement, }); } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/section/section-default.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/section/section-default.element.ts index ac4ca73978..4bacf832bd 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/section/section-default.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/section/section-default.element.ts @@ -75,7 +75,9 @@ export class UmbSectionDefaultElement extends UmbLitElement implements UmbSectio // TODO: we only support extensions with an element prop const extensionsWithElement = sectionRouteExtensions.filter((extension) => extension.manifest.element); const extensionsWithoutElement = sectionRouteExtensions.filter((extension) => !extension.manifest.element); - if (extensionsWithoutElement.length > 0) throw new Error('sectionRoute extensions must have an element'); + if (extensionsWithoutElement.length > 0) { + throw new Error('sectionRoute extensions must have an element'); + } const routes: Array = await Promise.all( extensionsWithElement.map(async (extensionController) => { diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts index 27de8edc03..eb725fc2ae 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/current-user.context.ts @@ -7,11 +7,7 @@ import { filter, firstValueFrom } from '@umbraco-cms/backoffice/external/rxjs'; import { UMB_AUTH_CONTEXT } from '@umbraco-cms/backoffice/auth'; import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; import { umbLocalizationRegistry } from '@umbraco-cms/backoffice/localization'; -import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry'; -import { UMB_SECTION_PATH_PATTERN } from '@umbraco-cms/backoffice/section'; -import { ensurePathEndsWithSlash } from '@umbraco-cms/backoffice/utils'; import type { UmbReferenceByUnique } from '@umbraco-cms/backoffice/models'; -import { UMB_SERVER_CONTEXT } from '@umbraco-cms/backoffice/server'; export class UmbCurrentUserContext extends UmbContextBase { #currentUser = new UmbObjectState(undefined); @@ -60,7 +56,6 @@ export class UmbCurrentUserContext extends UmbContextBase if (asObservable) { await this.observe(asObservable(), (currentUser) => { this.#currentUser?.setValue(currentUser); - this.#redirectToFirstAllowedSectionIfNeeded(); }).asPromise(); } } @@ -228,42 +223,6 @@ export class UmbCurrentUserContext extends UmbContextBase } }); } - - async #redirectToFirstAllowedSectionIfNeeded() { - const url = new URL(window.location.href); - - const serverContext = await this.getContext(UMB_SERVER_CONTEXT); - if (!serverContext) { - throw new Error('Server context not available'); - } - const backofficePath = serverContext.getBackofficePath(); - - if (url.pathname === backofficePath || url.pathname === ensurePathEndsWithSlash(backofficePath)) { - const sectionManifest = await this.#firstAllowedSection(); - if (!sectionManifest) return; - - const fallbackSectionPath = UMB_SECTION_PATH_PATTERN.generateLocal({ - sectionName: sectionManifest.meta.pathname, - }); - - history.pushState(null, '', fallbackSectionPath); - } - } - - async #firstAllowedSection() { - const currentUser = this.#currentUser.getValue(); - if (!currentUser) return; - - /* TODO: this solution is not bullet proof as we still rely on the "correct" section to be registered at this point in time so we can get the path. - It probably would have been better if we used the section alias instead as the path. - Then we would have it available at all times and it also ensured a unique path. */ - const sections = await this.observe( - umbExtensionsRegistry.byTypeAndAliases('section', currentUser.allowedSections), - () => {}, - ).asPromise(); - - return sections[0]; - } } export default UmbCurrentUserContext;