getAttribute(UserEntity::class); $path = $request->getUri()->getPath(); if (strpos($path, '/auth/') !== false) { return $handler->handle($request); } if (!$user) { throw new UnauthorizedException(); } if ($user->getStatus() !== Status::ACTIVE) { throw new UnauthorizedException(); } if (strpos($path, '/admin') !== false && $user->getRole() !== Role::ADMIN) { throw new UnauthorizedException(); } return $handler->handle($request); } }