Updated RefreshToken methods

This commit is contained in:
Alex Bilbie 2016-01-12 23:00:05 +00:00
parent 5f9feda80c
commit 6339524c86
3 changed files with 62 additions and 14 deletions

View File

@ -1,17 +1,42 @@
<?php
namespace League\OAuth2\Server\Entities\Interfaces;
interface RefreshTokenEntityInterface extends TokenInterface
interface RefreshTokenEntityInterface
{
/**
* Set the original access token that the refresh token was associated with
* Get the token's identifier
* @return string
*/
public function getIdentifier();
/**
* Set the token's identifier
* @param $identifier
*/
public function setIdentifier($identifier);
/**
* Get the token's expiry date time
* @return \DateTime
*/
public function getExpiryDateTime();
/**
* Set the date time when the token expires
* @param \DateTime $dateTime
*/
public function setExpiryDateTime(\DateTime $dateTime);
/**
* Set the access token that the refresh token was associated with
*
* @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessToken
*/
public function setOriginalAccessToken(AccessTokenEntityInterface $accessToken);
public function setAccessToken(AccessTokenEntityInterface $accessToken);
/**
* Get the access token that the refresh token was originally associated with
* @return \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface
*/
public function getOriginalAccessToken();
public function getAccessToken();
}

View File

@ -12,5 +12,5 @@ use League\OAuth2\Server\Entities\Traits\TokenEntityTrait;
*/
class RefreshTokenEntity implements RefreshTokenEntityInterface
{
use EntityTrait, TokenEntityTrait, RefreshTokenTrait;
use EntityTrait, RefreshTokenTrait;
}

View File

@ -1,6 +1,7 @@
<?php
namespace League\OAuth2\Server\Entities\Traits;
use DateTime;
use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface;
trait RefreshTokenTrait
@ -8,23 +9,45 @@ trait RefreshTokenTrait
/**
* @var AccessTokenEntityInterface
*/
protected $originalAccessToken;
protected $accessToken;
/**
* Set the original access token that the refresh token was associated with
* @param \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface $accessToken
* @var DateTime
*/
public function setOriginalAccessToken(AccessTokenEntityInterface $accessToken)
protected $expiryDateTime;
/**
* @inheritdoc
*/
public function setAccessToken(AccessTokenEntityInterface $accessToken)
{
$this->originalAccessToken = $accessToken;
$this->accessToken = $accessToken;
}
/**
* Get the access token that the refresh token was originally associated with
* @return \League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface
* @inheritdoc
*/
public function getOriginalAccessToken()
public function getAccessToken()
{
return $this->originalAccessToken;
return $this->accessToken;
}
/**
* Get the token's expiry date time
* @return DateTime
*/
public function getExpiryDateTime()
{
return $this->expiryDateTime;
}
/**
* Set the date time when the token expires
*
* @param DateTime $dateTime
*/
public function setExpiryDateTime(DateTime $dateTime)
{
$this->expiryDateTime = $dateTime;
}
}