<?php
// auth/protect_admin.php

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

// Cek apakah session user ada
if (!isset($_SESSION['user'])) {
    header("Location: /presensi_v1/auth/login.php");
    exit;
}

// Cek role, hanya admin/operator yang boleh masuk
$role = $_SESSION['user']['role'];

if ($role !== 'superadmin' && $role !== 'operator') {
    header("Location: /presensi_v1/preview.php");
    exit;
}
