[MNT-21636] Use URLTree for redirect (#6691)

* use URLTree for redirect

* use always urltree

* fix e2e

* fix
This commit is contained in:
Eugenio Romano
2021-02-18 17:42:57 +00:00
committed by GitHub
parent 81f9f482b2
commit 4a381b46a5
8 changed files with 49 additions and 83 deletions

View File

@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router';
import { AuthenticationService } from './authentication.service';
import { AppConfigService } from '../app-config/app-config.service';
import { AuthGuardBase } from './auth-guard-base';
@@ -67,11 +67,11 @@ export class AuthGuard extends AuthGuardBase {
}
}
async checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Promise<boolean> {
async checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Promise<boolean | UrlTree> {
if (this.authenticationService.isLoggedIn() || this.withCredentials) {
return true;
}
return this.redirectToUrl( redirectUrl);
return this.redirectToUrl(redirectUrl);
}
}