agrege el front

This commit is contained in:
matias mella
2021-07-12 23:39:39 -04:00
parent ef48a97520
commit 226811d0e7
33 changed files with 12893 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { Injectable } from '@angular/core';
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
import { Observable } from 'rxjs';
import {AuthService} from "@auth0/auth0-angular";
import {tap} from "rxjs/operators";
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(private auth: AuthService,private router: Router) {
}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.auth.isAuthenticated$.pipe(
tap( loggedIn =>{
if(loggedIn){
console.log('tiene permiso mi rey');
}else {
console.log('no puede ingresar mi rey')
this.router.navigate(['/public']);
}
})
)
}
}