Source of file AuthCodeRepository.php
Size: 1,436 Bytes - Last Modified: 2021-12-24T05:17:09+00:00
/var/www/docs.ssmods.com/process/src/code/Repositories/AuthCodeRepository.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <?php /** * @author Ian Simpson <ian@iansimpson.nz> * @copyright Copyright (c) Ian Simpson */ namespace IanSimpson\OAuth2\Repositories; use League\OAuth2\Server\Entities\AuthCodeEntityInterface; use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface; use IanSimpson\OAuth2\Entities\AuthCodeEntity; class AuthCodeRepository implements AuthCodeRepositoryInterface { public function getAuthCode($codeId) { $codes = AuthCodeEntity::get()->filter([ 'Code' => $codeId, ]); return $codes->first(); } /** * {@inheritdoc} */ public function persistNewAuthCode(AuthCodeEntityInterface $authCode) { /** @var AuthCodeEntity $authCodeEntity */ $authCodeEntity = $authCode; $authCodeEntity->Code = $authCodeEntity->getIdentifier(); $authCodeEntity->write(); } /** * {@inheritdoc} */ public function revokeAuthCode($codeId) { // Some logic to revoke the auth code in a database $code = $this->getAuthCode($codeId); $code->Revoked = true; $code->write(); } /** * {@inheritdoc} */ public function isAuthCodeRevoked($codeId) { $code = $this->getAuthCode($codeId); return (bool) $code->Revoked; } /** * {@inheritdoc} */ public function getNewAuthCode() { return new AuthCodeEntity(); } } |