mirror of
https://github.com/webmasterskaya/joomla-oauth-server.git
synced 2024-11-24 02:44:51 +03:00
Update php doc and properties types
This commit is contained in:
parent
e8727b787c
commit
665f4ac2d4
@ -43,30 +43,31 @@ class RefreshTokenRepository implements RefreshTokenRepositoryInterface
|
|||||||
return new RefreshToken();
|
return new RefreshToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity)
|
/**
|
||||||
{
|
* @param RefreshTokenEntityInterface $refreshTokenEntity
|
||||||
$found = false;
|
*
|
||||||
try
|
* @return void
|
||||||
|
* @throws UniqueTokenIdentifierConstraintViolationException
|
||||||
|
* @throws \Exception
|
||||||
|
* @since version
|
||||||
|
*/
|
||||||
|
public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity): void
|
||||||
{
|
{
|
||||||
$refreshToken = $this->refreshTokenModel->getItemByIdentifier($refreshTokenEntity->getIdentifier());
|
$refreshToken = $this->refreshTokenModel->getItemByIdentifier($refreshTokenEntity->getIdentifier());
|
||||||
|
|
||||||
if ($refreshToken->id > 0)
|
if ($refreshToken !== false)
|
||||||
{
|
|
||||||
$found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($found)
|
|
||||||
{
|
{
|
||||||
throw UniqueTokenIdentifierConstraintViolationException::create();
|
throw UniqueTokenIdentifierConstraintViolationException::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $refreshTokenEntity->getData();
|
$data = $refreshTokenEntity->getData();
|
||||||
|
|
||||||
$accessToken = $this->accessTokenModel->getItemByIdentifier($refreshTokenEntity->getAccessToken()->getIdentifier());
|
$accessToken = $this->accessTokenModel->getItemByIdentifier($data['access_token_identifier']);
|
||||||
|
|
||||||
|
if ($accessToken === false)
|
||||||
|
{
|
||||||
|
throw new \RuntimeException($this->accessTokenModel->getError());
|
||||||
|
}
|
||||||
|
|
||||||
unset($data['access_token_identifier']);
|
unset($data['access_token_identifier']);
|
||||||
$data['access_token_id'] = $accessToken->id;
|
$data['access_token_id'] = $accessToken->id;
|
||||||
@ -79,15 +80,22 @@ class RefreshTokenRepository implements RefreshTokenRepositoryInterface
|
|||||||
$this->refreshTokenModel->revoke($tokenId);
|
$this->refreshTokenModel->revoke($tokenId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $tokenId
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
* @since version
|
||||||
|
* @noinspection PhpPossiblePolymorphicInvocationInspection
|
||||||
|
*/
|
||||||
public function isRefreshTokenRevoked($tokenId): bool
|
public function isRefreshTokenRevoked($tokenId): bool
|
||||||
{
|
{
|
||||||
$refreshToken = $this->refreshTokenModel->getItemByIdentifier($tokenId);
|
$refreshToken = $this->refreshTokenModel->getItemByIdentifier($tokenId);
|
||||||
|
|
||||||
if (empty($refreshToken->id))
|
if ($refreshToken === false)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!$refreshToken->revoked;
|
return (bool) $refreshToken->revoked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user