2016-02-14 23:20:10 +05:30
|
|
|
<?php
|
2016-11-27 03:13:42 +05:30
|
|
|
namespace api\components\OAuth2\Entities;
|
2016-02-14 23:20:10 +05:30
|
|
|
|
2019-08-23 13:58:04 +05:30
|
|
|
use api\components\OAuth2\Repositories\SessionStorage;
|
2016-11-30 04:49:14 +05:30
|
|
|
use ErrorException;
|
2016-02-23 03:19:46 +05:30
|
|
|
use League\OAuth2\Server\Entity\SessionEntity as OriginalSessionEntity;
|
2016-02-14 23:20:10 +05:30
|
|
|
|
|
|
|
class AccessTokenEntity extends \League\OAuth2\Server\Entity\AccessTokenEntity {
|
|
|
|
|
|
|
|
protected $sessionId;
|
|
|
|
|
|
|
|
public function getSessionId() {
|
|
|
|
return $this->sessionId;
|
|
|
|
}
|
|
|
|
|
2016-11-30 04:49:14 +05:30
|
|
|
public function setSessionId($sessionId) {
|
|
|
|
$this->sessionId = $sessionId;
|
|
|
|
}
|
|
|
|
|
2016-02-14 23:20:10 +05:30
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
* @return static
|
|
|
|
*/
|
2016-02-23 03:19:46 +05:30
|
|
|
public function setSession(OriginalSessionEntity $session) {
|
2016-02-14 23:20:10 +05:30
|
|
|
parent::setSession($session);
|
|
|
|
$this->sessionId = $session->getId();
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-11-30 04:49:14 +05:30
|
|
|
public function getSession() {
|
|
|
|
if ($this->session instanceof OriginalSessionEntity) {
|
|
|
|
return $this->session;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sessionStorage = $this->server->getSessionStorage();
|
|
|
|
if (!$sessionStorage instanceof SessionStorage) {
|
|
|
|
throw new ErrorException('SessionStorage must be instance of ' . SessionStorage::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $sessionStorage->getById($this->sessionId);
|
|
|
|
}
|
|
|
|
|
2016-02-14 23:20:10 +05:30
|
|
|
}
|