Добавлено запоминание client_redirect_uri при oauth авторизации

This commit is contained in:
ErickSkrauch
2016-11-05 18:02:46 +03:00
parent fe4e62af39
commit bc2f1d4ce9
5 changed files with 47 additions and 43 deletions

View File

@@ -110,34 +110,6 @@ class Account extends ActiveRecord {
return $this->hasMany(AccountSession::class, ['account_id' => 'id']);
}
/**
* Метод проверяет, может ли текущий пользователь быть автоматически авторизован
* для указанного клиента без запроса доступа к необходимому списку прав
*
* @param OauthClient $client
* @param \League\OAuth2\Server\Entity\ScopeEntity[] $scopes
*
* TODO: этому методу здесь не место.
*
* @return bool
*/
public function canAutoApprove(OauthClient $client, array $scopes = []) : bool {
if ($client->is_trusted) {
return true;
}
/** @var OauthSession|null $session */
$session = $this->getOauthSessions()->andWhere(['client_id' => $client->id])->one();
if ($session !== null) {
$existScopes = $session->getScopes()->members();
if (empty(array_diff(array_keys($scopes), $existScopes))) {
return true;
}
}
return false;
}
/**
* Выполняет проверку, принадлежит ли этому нику аккаунт у Mojang
*

View File

@@ -5,14 +5,15 @@ use common\components\redis\Set;
use yii\db\ActiveRecord;
/**
* This is the model class for table "oauth_access_tokens".
*
* Поля:
* @property string $access_token
* @property string $session_id
* @property integer $expire_time
*
* Геттеры:
* @property Set $scopes
*
* Отношения:
* @property OauthSession $session
*/
class OauthAccessToken extends ActiveRecord {
@@ -26,7 +27,7 @@ class OauthAccessToken extends ActiveRecord {
}
public function getScopes() {
return new Set($this->getDb()->getSchema()->getRawTableName($this->tableName()), $this->access_token, 'scopes');
return new Set(static::getDb()->getSchema()->getRawTableName(static::tableName()), $this->access_token, 'scopes');
}
public function beforeDelete() {