|
|
@@ -3,6 +3,7 @@ import { ActivatedRouteSnapshot, CanActivate, Router } from '@angular/router';
|
|
|
import { Observable } from 'rxjs';
|
|
|
import { tap } from 'rxjs/operators';
|
|
|
|
|
|
+import { getAppConfig } from '../../app.config';
|
|
|
import { AuthService } from '../auth/auth.service';
|
|
|
|
|
|
/**
|
|
|
@@ -13,13 +14,21 @@ import { AuthService } from '../auth/auth.service';
|
|
|
providedIn: 'root',
|
|
|
})
|
|
|
export class AuthGuard implements CanActivate {
|
|
|
- constructor(private router: Router, private authService: AuthService) {}
|
|
|
+ private readonly externalLoginUrl: string | undefined;
|
|
|
+
|
|
|
+ constructor(private router: Router, private authService: AuthService) {
|
|
|
+ this.externalLoginUrl = getAppConfig().loginUrl;
|
|
|
+ }
|
|
|
|
|
|
canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
|
|
|
return this.authService.checkAuthenticatedStatus().pipe(
|
|
|
tap(authenticated => {
|
|
|
if (!authenticated) {
|
|
|
- this.router.navigate(['/login']);
|
|
|
+ if (this.externalLoginUrl) {
|
|
|
+ window.location.href = this.externalLoginUrl;
|
|
|
+ } else {
|
|
|
+ this.router.navigate(['/login']);
|
|
|
+ }
|
|
|
}
|
|
|
}),
|
|
|
);
|