Первичное портирование логики сервера авторизации с PhalconPHP на Yii2

This commit is contained in:
ErickSkrauch
2016-08-21 02:21:39 +03:00
parent d0fcc8cd6f
commit b57b015f66
24 changed files with 573 additions and 9 deletions

View File

@@ -0,0 +1,37 @@
<?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;
}
}