|
|
|
@ -1,11 +1,10 @@
|
|
|
|
|
import { Injectable, inject } from '@angular/core';
|
|
|
|
|
import { UrlTree, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
|
|
|
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
|
|
|
|
|
|
|
|
import { Observable, delay, of, tap } from 'rxjs';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import { OAuthService } from 'angular-oauth2-oidc';
|
|
|
|
|
|
|
|
|
|
import { AuthService, HttpErrorReporterService, IAbpGuard } from '@abp/ng.core';
|
|
|
|
|
import { AuthService, IAbpGuard } from '@abp/ng.core';
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root',
|
|
|
|
@ -13,7 +12,6 @@ import { AuthService, HttpErrorReporterService, IAbpGuard } from '@abp/ng.core';
|
|
|
|
|
export class AbpOAuthGuard implements IAbpGuard {
|
|
|
|
|
protected readonly oAuthService = inject(OAuthService);
|
|
|
|
|
protected readonly authService = inject(AuthService);
|
|
|
|
|
protected readonly httpErrorReporter = inject(HttpErrorReporterService);
|
|
|
|
|
|
|
|
|
|
canActivate(
|
|
|
|
|
route: ActivatedRouteSnapshot,
|
|
|
|
@ -23,6 +21,7 @@ export class AbpOAuthGuard implements IAbpGuard {
|
|
|
|
|
if (hasValidAccessToken) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const params = { returnUrl: state.url };
|
|
|
|
|
this.authService.navigateToLogin(params);
|
|
|
|
|
return false;
|
|
|
|
|