Vérification des droits d'admin pour ajouter
avions/dz/type de sauts
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user