Vérification des droits d'admin pour ajouter

avions/dz/type de sauts
This commit is contained in:
Sébastien André
2021-03-17 17:21:23 +01:00
parent ba268e739f
commit 76d3943151
15 changed files with 76 additions and 100 deletions
@@ -1,23 +1,14 @@
import { Injectable } from "@angular/core";
import {
CanActivate,
Router,
ActivatedRouteSnapshot,
RouterStateSnapshot
} from "@angular/router";
import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot } from "@angular/router";
import { AuthenticationService } from "./authentication.service";
@Injectable({ providedIn: "root" })
export class AuthGuardService implements CanActivate {
constructor(
private router: Router,
private authenticationService: AuthenticationService
) {}
constructor(private router: Router,
private authenticationService: AuthenticationService) {}
public canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
) {
public canActivate(route: ActivatedRouteSnapshot,
state: RouterStateSnapshot) {
const currentUser = this.authenticationService.currentUserValue;
if (currentUser) {
// logged in so return true
@@ -25,10 +16,9 @@ export class AuthGuardService implements CanActivate {
}
// not logged in so redirect to login page with the return url
this.router.navigate(["/login"], {
skipLocationChange: true,
queryParams: { returnUrl: state.url }
});
this.router.navigate(["/login"],
{skipLocationChange: true, queryParams: { returnUrl: state.url }});
return false;
}
}