<?php
if ( !$user['superAdmin'] ) {
    http_response_code(401);
    exit;
}

if ( !$ua = $_GET['ua'] ) {
    http_response_code(400);
    exit;
}

$agents = $db->run("SELECT user.id, user.name, auth_token.consumedBy, auth_token.ua, auth_token.expiresAt, auth_token.consumedAt FROM `auth_token`, user WHERE ua = ? AND consumedBy IS NOT NULL AND user.clientId != 0 AND user.id = `auth_token`.consumedBy GROUP BY name, ua ORDER BY name DESC", $ua);

$deviceUsers = array_unique(array_column($agents, 'name'));

?>
<pre>
    <?php print_r($deviceUsers); ?>
</pre>