accounts/api/modules/authserver/models/AuthenticateData.php
2018-04-17 23:47:25 +03:00

45 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace api\modules\authserver\models;
use common\models\MinecraftAccessKey;
class AuthenticateData {
/**
* @var MinecraftAccessKey
*/
private $minecraftAccessKey;
public function __construct(MinecraftAccessKey $minecraftAccessKey) {
$this->minecraftAccessKey = $minecraftAccessKey;
}
public function getMinecraftAccessKey(): MinecraftAccessKey {
return $this->minecraftAccessKey;
}
public function getResponseData(bool $includeAvailableProfiles = false): array {
$accessKey = $this->minecraftAccessKey;
$account = $accessKey->account;
$result = [
'accessToken' => $accessKey->access_token,
'clientToken' => $accessKey->client_token,
'selectedProfile' => [
'id' => $account->uuid,
'name' => $account->username,
'legacy' => false,
],
];
if ($includeAvailableProfiles) {
// Сами моянги ещё ничего не придумали с этими availableProfiles
$availableProfiles[0] = $result['selectedProfile'];
$result['availableProfiles'] = $availableProfiles;
}
return $result;
}
}