<?php
/**
 * Auth Controller for Login/Logout
 */
class AuthController {
    
    public function logout() {
        // Clear session
        $_SESSION = array();
        
        // Destroy session cookie
        if (ini_get("session.use_cookies")) {
            $params = session_get_cookie_params();
            setcookie(session_name(), '', time() - 42000,
                $params["path"], $params["domain"],
                $params["secure"], $params["httponly"]
            );
        }
        
        // Destroy session
        session_destroy();
        
        // Redirect to login
        header('Location: ' . BASE_URL);
        exit;
    }
    
    public function loginForm() {
        // If already logged in, redirect to dashboard
        if (isset($_SESSION['user_id'])) {
            header('Location: ' . BASE_URL . '/dashboard');
            exit;
        }
        
        // Show login form (your index.php already handles this)
        include BASE_PATH . '/index.php';
    }
}