0

I'm trying to use canActivate guard in angular to validate url parameters. I'm trying to redirect to /node-info, my validation returns true if the url params exist.

The redirect is re-directing to the home page at the moment and I can't figure out why.

canActivate(route: ActivatedRouteSnapshot): Observable<boolean | UrlTree> {

...validation code ...

//Re-direct to '/node-info' if the url params are invalid, return url tree
    if (this.match === false) {`enter code here`
                return of(this._router.parseUrl('/node-info'));
                }

   //Dispatch action from store and allow route through
            if (this.match === true) {
                this._store.dispatch(new SelectNodeInfoAction({systemId, nodeName}));
   //dispatch from store based on systemId and nodeName after they have been validated
                return this._store.pipe(
                    select(getNodeInfoSelectedItem),
                    filter((item: ResourceResponseItem<NodeInfo>, index: number) => index >= 1 || itemIsMatch(item)),
                    map(item => itemIsMatch(item) ),
                );
            }
        }
kool
  • 3,214
  • 1
  • 10
  • 26

0 Answers0