Исправлена логика авторизации, чтобы не требовать отсутствия Bearer токена для случаев, когда авторизация не требуется

This commit is contained in:
ErickSkrauch
2017-04-04 14:59:23 +03:00
parent 667c034aca
commit db1d41449c
3 changed files with 2 additions and 61 deletions

View File

@ -24,6 +24,7 @@ use yii\web\User as YiiUserComponent;
* @property AccountIdentity|null $identity
*
* @method AccountIdentity|null loginByAccessToken($token, $type = null)
* @method AccountIdentity|null getIdentity($autoRenew = true)
*/
class Component extends YiiUserComponent {
@ -44,8 +45,6 @@ class Component extends YiiUserComponent {
public $sessionTimeout = 'P7D';
private $_identity;
public function init() {
parent::init();
if (!$this->secret) {
@ -53,24 +52,6 @@ class Component extends YiiUserComponent {
}
}
/**
* @param bool $autoRenew
* @return null|AccountIdentity
*/
public function getIdentity($autoRenew = true) {
$result = parent::getIdentity($autoRenew);
if ($result === null && $this->_identity !== false) {
$bearer = $this->getBearerToken();
if ($bearer !== null) {
$result = $this->loginByAccessToken($bearer);
}
$this->_identity = $result ?: false;
}
return $result;
}
/**
* @param IdentityInterface $identity
* @param bool $rememberMe