mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3181] Auth Guard - redirect by string url (#3474)
* redirect by string url * auth guard tests fix * revise
This commit is contained in:
committed by
Eugenio Romano
parent
0cf2a35983
commit
c0de0d5087
@@ -17,8 +17,7 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Router,
|
||||
PRIMARY_OUTLET, UrlTree, UrlSegmentGroup, UrlSegment
|
||||
ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Router
|
||||
} from '@angular/router';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
@@ -44,9 +43,7 @@ export class AuthGuardEcm implements CanActivate {
|
||||
return true;
|
||||
}
|
||||
|
||||
const navigation = this.getNavigationCommands(redirectUrl);
|
||||
|
||||
this.authService.setRedirect({ provider: 'ECM', navigation });
|
||||
this.authService.setRedirect({ provider: 'ECM', url: redirectUrl });
|
||||
const pathToLogin = this.getRouteDestinationForLogin();
|
||||
this.router.navigate(['/' + pathToLogin]);
|
||||
|
||||
@@ -58,20 +55,4 @@ export class AuthGuardEcm implements CanActivate {
|
||||
this.appConfig.get<string>('loginRoute') ?
|
||||
this.appConfig.get<string>('loginRoute') : 'login';
|
||||
}
|
||||
|
||||
private getNavigationCommands(redirectUrl: string): any[] {
|
||||
const urlTree: UrlTree = this.router.parseUrl(redirectUrl);
|
||||
const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET];
|
||||
|
||||
if (!urlSegmentGroup) {
|
||||
return [redirectUrl];
|
||||
}
|
||||
|
||||
const urlSegments: UrlSegment[] = urlSegmentGroup.segments;
|
||||
|
||||
return urlSegments.reduce(function(acc, item) {
|
||||
acc.push(item.path, item.parameters);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user