Return user field when requestUser param received on authentication/refresh endpoint [deploy]

This commit is contained in:
ErickSkrauch
2021-03-06 10:37:58 +01:00
parent 077db4f328
commit 1aed8f59cb
6 changed files with 149 additions and 61 deletions

View File

@ -34,10 +34,16 @@ class AuthenticationForm extends ApiForm {
*/
public $clientToken;
/**
* @var string|bool
*/
public $requestUser;
public function rules(): array {
return [
[['username', 'password', 'clientToken'], RequiredValidator::class],
[['clientToken'], ClientTokenValidator::class],
[['requestUser'], 'boolean'],
];
}
@ -85,7 +91,7 @@ class AuthenticationForm extends ApiForm {
/** @var Account $account */
$account = $loginForm->getAccount();
$token = Yii::$app->tokensFactory->createForMinecraftAccount($account, $this->clientToken);
$dataModel = new AuthenticateData($account, (string)$token, $this->clientToken);
$dataModel = new AuthenticateData($account, (string)$token, $this->clientToken, (bool)$this->requestUser);
/** @var OauthSession|null $minecraftOauthSession */
$minecraftOauthSession = $account->getOauthSessions()
->andWhere(['client_id' => OauthClient::UNAUTHORIZED_MINECRAFT_GAME_LAUNCHER])