2016-08-21 04:51:39 +05:30
|
|
|
<?php
|
|
|
|
namespace api\modules\authserver\models;
|
|
|
|
|
2017-05-31 05:40:22 +05:30
|
|
|
use api\models\base\ApiForm;
|
2016-08-21 04:51:39 +05:30
|
|
|
use api\modules\authserver\validators\RequiredValidator;
|
|
|
|
use common\models\MinecraftAccessKey;
|
|
|
|
|
2017-05-31 05:40:22 +05:30
|
|
|
class InvalidateForm extends ApiForm {
|
2016-08-21 04:51:39 +05:30
|
|
|
|
|
|
|
public $accessToken;
|
|
|
|
public $clientToken;
|
|
|
|
|
|
|
|
public function rules() {
|
|
|
|
return [
|
|
|
|
[['accessToken', 'clientToken'], RequiredValidator::class],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
* @throws \api\modules\authserver\exceptions\AuthserverException
|
|
|
|
*/
|
|
|
|
public function invalidateToken() : bool {
|
|
|
|
$this->validate();
|
|
|
|
|
|
|
|
$token = MinecraftAccessKey::findOne([
|
|
|
|
'access_token' => $this->accessToken,
|
|
|
|
'client_token' => $this->clientToken,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if ($token !== null) {
|
|
|
|
$token->delete();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|