2024-10-17 08:48:15 +00:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
|
|
|
import { ApiAuthenticationService } from '../services/api/api-authentication.service';
|
|
|
|
|
|
|
|
@Injectable({
|
2024-10-31 05:33:11 +00:00
|
|
|
providedIn: 'root'
|
2024-10-17 08:48:15 +00:00
|
|
|
})
|
2024-10-31 05:33:11 +00:00
|
|
|
export class AuthUserGuard implements CanActivate {
|
2024-10-17 08:48:15 +00:00
|
|
|
|
2024-10-31 05:33:11 +00:00
|
|
|
constructor(private auth: ApiAuthenticationService, private router: Router) { }
|
2024-10-17 08:48:15 +00:00
|
|
|
|
|
|
|
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
2024-10-31 05:33:11 +00:00
|
|
|
return this.auth.isAuthenticated();
|
2024-10-17 08:48:15 +00:00
|
|
|
}
|
|
|
|
}
|