<?php

namespace App\Modules\Pilkades\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class EnsureAdminDesa
{
    public function handle(Request $request, Closure $next): Response
    {
        if (! $request->user() || ! $request->user()->isAdminDesa() || ! $request->user()->desa_id) {
            abort(403);
        }

        return $next($request);
    }
}
