<?php
require __DIR__.'/_bootstrap.php';

use Zoo\Database;
use Zoo\Auth\PlayerAuthService;
use Zoo\Account\BindService;

try{
    $db=Database::connect();
    $player=(new PlayerAuthService($db))->authenticate([]);
    $binding=(new BindService($db))->status((int)$player['user_id']);

    json_out([
        'ok'=>true,
        'internal_login'=>[
            'bound'=>!empty($binding['internal_login_id']),
            'login_id'=>$binding['internal_login_id'],
            'bound_at'=>$binding['internal_login_bound_at']
        ]
    ]);
}catch(Throwable $e){
    json_out(['ok'=>false,'error'=>$e->getMessage()],400);
}
