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 @@