import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common';
import { UserRole } from '../user/user-role.enum';

@Injectable()
export class SuperAdminGuard implements CanActivate {
    canActivate(context: ExecutionContext): boolean {
        const request = context.switchToHttp().getRequest();
        const user = request.user;
        return user && (user.role === UserRole.SUPER_ADMIN || user.isAdmin === true);
    }
}
