mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлено запоминание client_redirect_uri при oauth авторизации
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
@@ -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() {
|
||||
|
Reference in New Issue
Block a user