mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлен контроллер для блокировки аккаунта
Добавлен client_credentials grant для oAuth Рефакторинг структуры OauthScopes чтобы можно было разделить владельца прав на пользовательские и общие (машинные) Исправлена стилистика кода, внедряются фишки PHP 7.1
This commit is contained in:
@@ -6,8 +6,8 @@ use yii\web\User as YiiUserComponent;
|
||||
/**
|
||||
* @property Identity|null $identity
|
||||
*
|
||||
* @method Identity|null getIdentity()
|
||||
* @method Identity|null loginByAccessToken(string $token, $type = null)
|
||||
* @method Identity|null getIdentity($autoRenew = true)
|
||||
* @method Identity|null loginByAccessToken($token, $type = null)
|
||||
*/
|
||||
class Component extends YiiUserComponent {
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ class Identity implements IdentityInterface {
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function findIdentityByAccessToken($token, $type = null) {
|
||||
public static function findIdentityByAccessToken($token, $type = null): self {
|
||||
/** @var AccessTokenEntity|null $model */
|
||||
$model = Yii::$app->oauth->getAuthServer()->getAccessTokenStorage()->get($token);
|
||||
if ($model === null) {
|
||||
throw new UnauthorizedHttpException('Incorrect token');
|
||||
@@ -41,19 +42,19 @@ class Identity implements IdentityInterface {
|
||||
$this->_accessToken = $accessToken;
|
||||
}
|
||||
|
||||
public function getAccount() : Account {
|
||||
public function getAccount(): Account {
|
||||
return $this->getSession()->account;
|
||||
}
|
||||
|
||||
public function getClient() : OauthClient {
|
||||
public function getClient(): OauthClient {
|
||||
return $this->getSession()->client;
|
||||
}
|
||||
|
||||
public function getSession() : OauthSession {
|
||||
public function getSession(): OauthSession {
|
||||
return OauthSession::findOne($this->_accessToken->getSessionId());
|
||||
}
|
||||
|
||||
public function getAccessToken() : AccessTokenEntity {
|
||||
public function getAccessToken(): AccessTokenEntity {
|
||||
return $this->_accessToken;
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ class Identity implements IdentityInterface {
|
||||
* У нас права привязываются к токенам, так что возвращаем именно его id.
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getId() {
|
||||
public function getId(): string {
|
||||
return $this->_accessToken->getId();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user