<?php
require_once '../SessionManager.php';

class AuthMiddleware {
    public static function authenticate() {
        SessionManager::startSession();
        
        if (!SessionManager::isLoggedIn()) {
            http_response_code(401);
            echo json_encode(array('message' => 'Unauthorized'));
            exit();
        }
        
        return SessionManager::getCurrentUser();
    }

    public static function requireRole($required_role) {
        SessionManager::requireRole($required_role);
    }

    public static function requireAdmin() {
        SessionManager::requireAdmin();
    }
}
?>
