mirror of
https://github.com/elyby/accounts.git
synced 2024-11-16 10:14:02 +05:30
38 lines
812 B
PHP
38 lines
812 B
PHP
|
<?php
|
||
|
namespace api\modules\authserver\models;
|
||
|
|
||
|
use api\modules\authserver\validators\RequiredValidator;
|
||
|
use common\models\MinecraftAccessKey;
|
||
|
|
||
|
class InvalidateForm extends Form {
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
}
|