25 lines
747 B
TypeScript
Raw Normal View History

2025-06-06 07:38:11 -03:00
import { ActivatedRouteSnapshot, CanActivate, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
import { NavigationService } from '../core/services/common/navigation.service';
import { inject, Injectable } from '@angular/core';
2025-06-06 07:38:11 -03:00
@Injectable({
providedIn: 'root'
})
export class AppIdGuard implements CanActivate {
private navigationService = inject(NavigationService);
private router = inject(Router);
2025-06-06 07:38:11 -03:00
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): boolean {
const appId = next.params['appId'];
const currentAppId = this.navigationService.getCurrentAppId();
if (appId === currentAppId) {
return true;
}
this.router.navigate(['/404']);
return false;
}
}