<?php

declare(strict_types=1);

require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/../includes/mvc.php';
require_once __DIR__ . '/../includes/auth.php';

$result = auth_service()->login('admin', '123456');

echo 'Login success: ' . ($result->success ? 'YES' : 'NO') . PHP_EOL;
echo 'Message: ' . $result->message . PHP_EOL;

if ($result->user !== null) {
    echo 'Token: ' . substr($result->user->token, 0, 20) . '...' . PHP_EOL;
    echo 'User ID: ' . $result->user->userId . PHP_EOL;
    echo 'Login ID: ' . $result->user->loginId . PHP_EOL;
    echo 'User type: ' . $result->user->userType . PHP_EOL;
}

echo 'Authenticated: ' . (auth_service()->isAuthenticated() ? 'YES' : 'NO') . PHP_EOL;
