From 3cbda23592307400de57e1ff04a4838c8ef94f81 Mon Sep 17 00:00:00 2001 From: kpawelczak <42094017+kpawelczak@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:08:23 +0200 Subject: [PATCH] fix: Invalid CanActivate guard in cmsMapping (#19265) --- .../cms-structure/services/cms-guards.service.ts | 6 +++--- .../cms-structure/services/cms-routes-impl.service.ts | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/storefrontlib/cms-structure/services/cms-guards.service.ts b/projects/storefrontlib/cms-structure/services/cms-guards.service.ts index 5194b393448..c9787105971 100644 --- a/projects/storefrontlib/cms-structure/services/cms-guards.service.ts +++ b/projects/storefrontlib/cms-structure/services/cms-guards.service.ts @@ -4,16 +4,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { Injectable, inject } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { CanActivateFn, RouterStateSnapshot, UrlTree } from '@angular/router'; import { CmsActivatedRouteSnapshot, FeatureConfigService, - UnifiedInjector, getLastValueSync, + UnifiedInjector, wrapIntoObservable, } from '@spartacus/core'; -import { Observable, concat, of } from 'rxjs'; +import { concat, Observable, of } from 'rxjs'; import { endWith, first, skipWhile } from 'rxjs/operators'; import { CmsComponentsService } from './cms-components.service'; import { CanActivate, GuardsComposer } from './guards-composer'; diff --git a/projects/storefrontlib/cms-structure/services/cms-routes-impl.service.ts b/projects/storefrontlib/cms-structure/services/cms-routes-impl.service.ts index 7dff130f435..a7d04695ac6 100644 --- a/projects/storefrontlib/cms-structure/services/cms-routes-impl.service.ts +++ b/projects/storefrontlib/cms-structure/services/cms-routes-impl.service.ts @@ -135,9 +135,13 @@ export class CmsRoutesImplService { } if (route?.canActivate?.length) { - route.canActivate = route.canActivate.map((guard) => + const canActivate = route.canActivate.map((guard) => this.wrapCmsGuard(guard) ); + return { + ...route, + canActivate, + }; } return route;