2016-11-29 04:27:58 +05:30
|
|
|
<?php
|
|
|
|
namespace api\components\OAuth2\Entities;
|
|
|
|
|
2016-11-30 04:49:14 +05:30
|
|
|
use api\components\OAuth2\Storage\SessionStorage;
|
|
|
|
use ErrorException;
|
|
|
|
use League\OAuth2\Server\Entity\SessionEntity as OriginalSessionEntity;
|
|
|
|
|
2016-11-29 04:27:58 +05:30
|
|
|
class RefreshTokenEntity extends \League\OAuth2\Server\Entity\RefreshTokenEntity {
|
|
|
|
|
2016-11-30 04:49:14 +05:30
|
|
|
private $sessionId;
|
|
|
|
|
2016-11-29 04:27:58 +05:30
|
|
|
public function isExpired() : bool {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-30 04:49:14 +05:30
|
|
|
public function getSession() : SessionEntity {
|
|
|
|
if ($this->session instanceof SessionEntity) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSessionId() : int {
|
|
|
|
return $this->sessionId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSession(OriginalSessionEntity $session) {
|
|
|
|
parent::setSession($session);
|
|
|
|
$this->setSessionId($session->getId());
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSessionId(int $sessionId) {
|
|
|
|
$this->sessionId = $sessionId;
|
|
|
|
}
|
|
|
|
|
2016-11-29 04:27:58 +05:30
|
|
|
}
|