<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

function auth_check() {
    if (empty($_SESSION['user'])) {
        header("Location: /monitoring/auth/login.php");
        exit;
    }
}

function auth_user() {
    return $_SESSION['user'] ?? null;
}

function auth_is_admin() {
    return isset($_SESSION['user']) && $_SESSION['user']['role'] === 'admin';
}
