<?php
namespace App\Middleware;

use App\Core\Database;

class TenantMiddleware
{
    public static function apply()
    {
        if (!isset($_SESSION['user'])) {
            return;
        }

        if (is_superadmin()) {
            return; // no tenant restriction
        }

        $orgId = $_SESSION['user']['org_id'] ?? null;

        if (!$orgId) {
            http_response_code(403);
            exit('Organization scope missing.');
        }
    }
}
