Из базы удалена таблица oauth_scopes

This commit is contained in:
ErickSkrauch 2016-11-27 19:19:13 +03:00
parent 744ec9520a
commit 1e94cda399
4 changed files with 35 additions and 14 deletions

View File

@ -12,14 +12,12 @@ class ScopeStorage extends AbstractStorage implements ScopeInterface {
* @inheritdoc
*/
public function get($scope, $grantType = null, $clientId = null) {
/** @var OauthScope|null $row */
$row = OauthScope::findOne($scope);
if ($row === null) {
if (!in_array($scope, OauthScope::getScopes(), true)) {
return null;
}
$entity = new ScopeEntity($this->server);
$entity->setId($row->id);
$entity->setId($scope);
return $entity;
}

View File

@ -1,21 +1,20 @@
<?php
namespace common\models;
use yii\db\ActiveRecord;
/**
* Поля:
* @property string $id
*/
class OauthScope extends ActiveRecord {
class OauthScope {
const OFFLINE_ACCESS = 'offline_access';
const MINECRAFT_SERVER_SESSION = 'minecraft_server_session';
const ACCOUNT_INFO = 'account_info';
const ACCOUNT_EMAIL = 'account_email';
public static function tableName() {
return '{{%oauth_scopes}}';
public static function getScopes() : array {
return [
self::OFFLINE_ACCESS,
self::MINECRAFT_SERVER_SESSION,
self::ACCOUNT_INFO,
self::ACCOUNT_EMAIL,
];
}
}

View File

@ -0,0 +1,25 @@
<?php
use console\db\Migration;
class m161127_145211_remove_oauth_scopes extends Migration {
public function safeUp() {
$this->dropTable('{{%oauth_scopes}}');
}
public function safeDown() {
$this->createTable('{{%oauth_scopes}}', [
'id' => $this->string(64),
$this->primary('id'),
]);
$this->batchInsert('{{%oauth_scopes}}', ['id'], [
['offline_access'],
['minecraft_server_session'],
['account_info'],
['account_email'],
]);
}
}

View File

@ -1,7 +1,6 @@
<?php
namespace tests\codeception\common\fixtures;
use common\models\OauthScope;
use common\models\OauthSession;
use yii\test\ActiveFixture;