accounts/api/modules/authserver/models/InvalidateForm.php

40 lines
844 B
PHP
Raw Normal View History

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