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

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

// 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();

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

// Optional: Check if user has specific role
// AuthHelper::requireRole('admin');

// Optional: Check if user has any of these roles
// AuthHelper::requireAnyRole(['admin', 'manager']);

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

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