2016-08-21 04:51:39 +05:30
|
|
|
<?php
|
2019-12-04 23:40:15 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-08-21 04:51:39 +05:30
|
|
|
namespace api\modules\authserver\models;
|
|
|
|
|
2019-12-04 23:40:15 +05:30
|
|
|
use common\models\Account;
|
|
|
|
use Lcobucci\JWT\Token;
|
2016-08-21 04:51:39 +05:30
|
|
|
|
|
|
|
class AuthenticateData {
|
|
|
|
|
|
|
|
/**
|
2019-12-04 23:40:15 +05:30
|
|
|
* @var Account
|
2016-08-21 04:51:39 +05:30
|
|
|
*/
|
2019-12-04 23:40:15 +05:30
|
|
|
private $account;
|
2016-08-21 04:51:39 +05:30
|
|
|
|
2019-12-04 23:40:15 +05:30
|
|
|
/**
|
|
|
|
* @var Token
|
|
|
|
*/
|
|
|
|
private $accessToken;
|
2016-08-21 04:51:39 +05:30
|
|
|
|
2019-12-04 23:40:15 +05:30
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $clientToken;
|
|
|
|
|
|
|
|
public function __construct(Account $account, string $accessToken, string $clientToken) {
|
|
|
|
$this->account = $account;
|
|
|
|
$this->accessToken = $accessToken;
|
|
|
|
$this->clientToken = $clientToken;
|
2016-08-21 04:51:39 +05:30
|
|
|
}
|
|
|
|
|
2018-04-18 02:17:25 +05:30
|
|
|
public function getResponseData(bool $includeAvailableProfiles = false): array {
|
2016-08-21 04:51:39 +05:30
|
|
|
$result = [
|
2019-12-04 23:40:15 +05:30
|
|
|
'accessToken' => $this->accessToken,
|
|
|
|
'clientToken' => $this->clientToken,
|
2016-08-21 04:51:39 +05:30
|
|
|
'selectedProfile' => [
|
2019-12-04 23:40:15 +05:30
|
|
|
'id' => $this->account->uuid,
|
|
|
|
'name' => $this->account->username,
|
2016-08-21 04:51:39 +05:30
|
|
|
'legacy' => false,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
if ($includeAvailableProfiles) {
|
2019-12-04 23:40:15 +05:30
|
|
|
// The Mojang 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|