<?php

namespace App\Middleware;

use App\Utils\View;

class AdminMiddleware
{
    public function handle()
    {
        if (!isset($_SESSION['user_role']) || $_SESSION['user_role'] !== 'admin') {
            error_log("AdminMiddleware Redirecting: Session Role: " . ($_SESSION['user_role'] ?? 'NOT SET') . " | Session ID: " . session_id());
            View::redirect('/login');
            return false;
        }
        return true;
    }
}
