Fix bug on adminLoginGuard wrong redirectedUrl on canLoad.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56976 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-09-05 14:02:18 +00:00
parent 71d0c3ae4f
commit 9f3dafd895
2 changed files with 11 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper'; import {ConnectHelper} from '../connectHelper';
import {StringUtils} from '../../utils/string-utils.class';
@Injectable() @Injectable()
export class ConnectAdminLoginGuard implements CanActivate, CanLoad { export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
@ -52,7 +53,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
} }
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean { canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
const path = '/' + route.path + document.location.search; const path = StringUtils.URLSegmentsToPath(segments) + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path), path); return this.check(ConnectHelper.getCommunityFromPath(path), path);
} }
} }

View File

@ -1,3 +1,5 @@
import {UrlSegment} from '@angular/router';
export class Dates { export class Dates {
public static isValidYear(yearString){ public static isValidYear(yearString){
// First check for the pattern // First check for the pattern
@ -135,4 +137,11 @@ export class StringUtils{
return sliced + (String(mystr).length > size ? '...' : ''); return sliced + (String(mystr).length > size ? '...' : '');
} }
public static URLSegmentsToPath(segments: UrlSegment[]): string {
let path = '';
segments.forEach(route => {
path += '/' + route.path;
})
return path;
}
} }