From 1e94cda399d03ac14f27c6dbae470ed4de617729 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sun, 27 Nov 2016 19:19:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=20=D0=B1=D0=B0=D0=B7=D1=8B=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=86=D0=B0=20oauth=5Fscopes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OAuth2/Storage/ScopeStorage.php | 6 ++--- common/models/OauthScope.php | 17 ++++++------- .../m161127_145211_remove_oauth_scopes.php | 25 +++++++++++++++++++ .../common/fixtures/OauthSessionFixture.php | 1 - 4 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 console/migrations/m161127_145211_remove_oauth_scopes.php diff --git a/api/components/OAuth2/Storage/ScopeStorage.php b/api/components/OAuth2/Storage/ScopeStorage.php index 788f7e3..be42d1e 100644 --- a/api/components/OAuth2/Storage/ScopeStorage.php +++ b/api/components/OAuth2/Storage/ScopeStorage.php @@ -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; } diff --git a/common/models/OauthScope.php b/common/models/OauthScope.php index ab392bf..9fbf035 100644 --- a/common/models/OauthScope.php +++ b/common/models/OauthScope.php @@ -1,21 +1,20 @@ 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'], + ]); + } + +} diff --git a/tests/codeception/common/fixtures/OauthSessionFixture.php b/tests/codeception/common/fixtures/OauthSessionFixture.php index 0bbab87..fbeb903 100644 --- a/tests/codeception/common/fixtures/OauthSessionFixture.php +++ b/tests/codeception/common/fixtures/OauthSessionFixture.php @@ -1,7 +1,6 @@