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
@@ -18,7 +18,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot,
|
||||
Router, PRIMARY_OUTLET, UrlTree, UrlSegmentGroup, UrlSegment
|
||||
Router
|
||||
} from '@angular/router';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
@@ -45,9 +45,7 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
|
||||
}
|
||||
|
||||
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin() ) {
|
||||
const navigation = this.getNavigationCommands(redirectUrl);
|
||||
|
||||
this.authService.setRedirect({ provider: 'BPM', navigation });
|
||||
this.authService.setRedirect({ provider: 'BPM', url: redirectUrl });
|
||||
const pathToLogin = this.getRouteDestinationForLogin();
|
||||
this.router.navigate(['/' + pathToLogin]);
|
||||
}
|
||||
@@ -64,20 +62,4 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
|
||||
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