|
|
|
@ -1,15 +1,13 @@
|
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
|
|
|
|
import { Store } from '@ngxs/store';
|
|
|
|
|
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
|
|
|
|
import { OAuthService } from 'angular-oauth2-oidc';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import { Navigate } from '@ngxs/router-plugin';
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root',
|
|
|
|
|
})
|
|
|
|
|
export class AuthGuard implements CanActivate {
|
|
|
|
|
constructor(private oauthService: OAuthService, private store: Store, private router: Router) {}
|
|
|
|
|
constructor(private oauthService: OAuthService, private router: Router) {}
|
|
|
|
|
|
|
|
|
|
canActivate(_: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean | UrlTree {
|
|
|
|
|
const hasValidAccessToken = this.oauthService.hasValidAccessToken();
|
|
|
|
|