Skip to content
Snippets Groups Projects

Resolve "Reload redirige vers les news"

Merged Etienne LOUPIAS requested to merge 514-reload-redirige-vers-les-news into dev
2 files
+ 7
6
Compare changes
  • Side-by-side
  • Inline
Files
2
import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router';
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router';
import { ProfileService } from '../profile/services/profile.service';
import { AuthService } from '../services/auth.service';
import { RouteRole } from '../shared/enum/routeRole.enum';
@@ -15,14 +15,14 @@ export class RoleGuard {
private authService: AuthService,
) {}
canActivate(route: ActivatedRouteSnapshot): UrlTree | boolean {
async canActivate(route: ActivatedRouteSnapshot): Promise<UrlTree | boolean> {
const allowedRoles = route.data.allowedRoles;
if (this.authService.isLoggedIn()) {
if (this.profileService.isAdmin()) return true;
if (allowedRoles.includes(RouteRole.structureAdmin)) {
const structureId = route.params.id;
if (this.profileService.isLinkedToStructure(structureId)) {
if (await this.profileService.isLinkedToStructure(structureId)) {
return true;
}
}
Loading