2016-08-21 04:51:39 +05:30
|
|
|
<?php
|
|
|
|
namespace api\modules\authserver\models;
|
|
|
|
|
|
|
|
use common\models\MinecraftAccessKey;
|
|
|
|
|
|
|
|
class AuthenticateData {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var MinecraftAccessKey
|
|
|
|
*/
|
|
|
|
private $minecraftAccessKey;
|
|
|
|
|
|
|
|
public function __construct(MinecraftAccessKey $minecraftAccessKey) {
|
|
|
|
$this->minecraftAccessKey = $minecraftAccessKey;
|
|
|
|
}
|
|
|
|
|
2018-04-18 02:17:25 +05:30
|
|
|
public function getMinecraftAccessKey(): MinecraftAccessKey {
|
2016-08-21 04:51:39 +05:30
|
|
|
return $this->minecraftAccessKey;
|
|
|
|
}
|
|
|
|
|
2018-04-18 02:17:25 +05:30
|
|
|
public function getResponseData(bool $includeAvailableProfiles = false): array {
|
2016-08-21 04:51:39 +05:30
|
|
|
$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) {
|
2019-07-15 04:29:56 +05:30
|
|
|
// The Moiangs themselves haven't come up with anything yet with these availableProfiles
|
2016-08-21 04:51:39 +05:30
|
|
|
$availableProfiles[0] = $result['selectedProfile'];
|
|
|
|
$result['availableProfiles'] = $availableProfiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|