Source of file RefreshTokenRepository.php
Size: 1,547 Bytes - Last Modified: 2021-12-24T05:17:09+00:00
/var/www/docs.ssmods.com/process/src/code/Repositories/RefreshTokenRepository.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <?php /** * @author Ian Simpson <ian@iansimpson.nz> * @copyright Copyright (c) Ian Simpson */ namespace IanSimpson\OAuth2\Repositories; use League\OAuth2\Server\Entities\RefreshTokenEntityInterface; use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface; use IanSimpson\OAuth2\Entities\RefreshTokenEntity; class RefreshTokenRepository implements RefreshTokenRepositoryInterface { public function getRefreshToken($tokenId) { $clients = RefreshTokenEntity::get()->filter([ 'Code' => $tokenId, ]); return $clients->first(); } /** * {@inheritdoc} */ public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshToken) { /** @var RefreshTokenEntity $refreshTokenEntity */ $refreshTokenEntity = $refreshToken; $refreshTokenEntity->Code = $refreshTokenEntity->getIdentifier(); $refreshTokenEntity->write(); } /** * {@inheritdoc} */ public function revokeRefreshToken($tokenId) { // Some logic to revoke the refresh token in a database $token = $this->getRefreshToken($tokenId); $token->Revoked = true; $token->write(); } /** * {@inheritdoc} */ public function isRefreshTokenRevoked($tokenId) { $token = $this->getRefreshToken($tokenId); return (bool) $token->Revoked; } /** * {@inheritdoc} */ public function getNewRefreshToken() { return new RefreshTokenEntity(); } } |