Token is now linked to a user identifier instead of owner concept

This commit is contained in:
Alex Bilbie 2016-01-12 23:04:03 +00:00
parent de89a6bc89
commit 6358be90c2

View File

@ -17,15 +17,10 @@ trait TokenEntityTrait
*/ */
protected $expiryDateTime; protected $expiryDateTime;
/**
* @var string
*/
protected $ownerType;
/** /**
* @var string|int * @var string|int
*/ */
protected $ownerIdentifier; protected $userIdentifier;
/** /**
* @var ClientEntityInterface * @var ClientEntityInterface
@ -34,6 +29,7 @@ trait TokenEntityTrait
/** /**
* Associate a scope with the token * Associate a scope with the token
*
* @param \League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface $scope * @param \League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface $scope
*/ */
public function addScope(ScopeEntityInterface $scope) public function addScope(ScopeEntityInterface $scope)
@ -43,7 +39,9 @@ trait TokenEntityTrait
/** /**
* Get an associated scope by the scope's identifier * Get an associated scope by the scope's identifier
*
* @param string $identifier * @param string $identifier
*
* @return ScopeEntityInterface|null The scope or null if not found * @return ScopeEntityInterface|null The scope or null if not found
*/ */
public function getScopeWithIdentifier($identifier) public function getScopeWithIdentifier($identifier)
@ -57,7 +55,7 @@ trait TokenEntityTrait
*/ */
public function getScopes() public function getScopes()
{ {
return $this->scopes; return array_values($this->scopes);
} }
/** /**
@ -71,6 +69,7 @@ trait TokenEntityTrait
/** /**
* Set the date time when the token expires * Set the date time when the token expires
*
* @param DateTime $dateTime * @param DateTime $dateTime
*/ */
public function setExpiryDateTime(DateTime $dateTime) public function setExpiryDateTime(DateTime $dateTime)
@ -79,32 +78,22 @@ trait TokenEntityTrait
} }
/** /**
* Set the token's owner * Set the identifier of the user associated with the token
* @param string $type The type of the owner (e.g. "user", "client" or something more specific) *
* @param string|int $identifier The identifier of the owner * @param string|int $identifier The identifier of the user
*/ */
public function setOwner($type, $identifier) public function setUserIdentifier($identifier)
{ {
$this->ownerType = $type; $this->userIdentifier = $identifier;
$this->ownerIdentifier = $identifier;
} }
/** /**
* Get the token owner's type * Get the token user's identifier
* @return string The type of owner (e.g. "user", "client" or something more specific)
*/
public function getOwnerType()
{
return $this->ownerType;
}
/**
* Get the token owner's identifier
* @return string|int * @return string|int
*/ */
public function getOwnerIdentifier() public function getUserIdentifier()
{ {
return $this->ownerIdentifier; return $this->userIdentifier;
} }
/** /**
@ -118,6 +107,7 @@ trait TokenEntityTrait
/** /**
* Set the client that the token was issued to * Set the client that the token was issued to
*
* @param \League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface $client * @param \League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface $client
*/ */
public function setClient(ClientEntityInterface $client) public function setClient(ClientEntityInterface $client)