<?php
// app/config/session_check.php

/**
 * Include this file at the top of every protected page
 * to verify user is logged in and has admin role
 */

// Load required classes
use model\util\AuthHelper;
use model\util\SessionManager;

require_once __DIR__ . '/../core/SessionManager.php';
require_once __DIR__ . '/../core/AuthHelper.php';

// Start/verify session and require login
AuthHelper::requireLogin();

// Enforce admin role for protected pages
// This will redirect to access-denied.php if user is not admin
AuthHelper::requireRole('admin');

// Get current user data
$currentUser = AuthHelper::getCurrentUser();

// Generate CSRF token for forms
$csrfToken = SessionManager::getInstance()->generateCsrfToken();

// Get flash message if exists
$flashMessage = SessionManager::getInstance()->getFlashMessage();
?>
