<?php

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

require_once 'classes/Database.php';
require_once 'classes/User.php';
require_once 'classes/Logger.php';
require_once 'includes/auth.php';

$db = new Database();
$conn = $db->getConnection();

$logger = new Logger($conn, $_SESSION['user_id'] ?? null, $_SESSION['username'] ?? null, $_SESSION['role'] ?? null);

$user = new User($conn, $logger);
$auth = new Auth($conn);

$auth->requireLogin();

header('Location: ' . $auth->getDashboardUrl());
exit();