. // }}} /** * OAuth2 Client * * @package GNUsocial * * @author Hugo Sales * @copyright 2022 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace Plugin\OAuth2\Entity; use DateTimeInterface; use League\OAuth2\Server\Entities\AuthCodeEntityInterface; use Plugin\OAuth2\Repository; class AuthCode extends Token implements AuthCodeEntityInterface { // {{{ Autocode // @codeCoverageIgnoreStart private string $id; private DateTimeInterface $expiry; private ?int $user_id = null; private string $client_id; private string $token_scopes; private bool $revoked; private DateTimeInterface $created; public function setId(string $id): self { $this->id = mb_substr($id, 0, 64); return $this; } public function getId(): string { return $this->id; } public function setExpiry(DateTimeInterface $expiry): self { $this->expiry = $expiry; return $this; } public function getExpiry(): DateTimeInterface { return $this->expiry; } public function setUserId(?int $user_id): self { $this->user_id = $user_id; return $this; } public function getUserId(): ?int { return $this->user_id; } public function setClientId(string $client_id): self { $this->client_id = mb_substr($client_id, 0, 64); return $this; } public function getClientId(): string { return $this->client_id; } public function setTokenScopes(string $token_scopes): self { $this->token_scopes = $token_scopes; return $this; } public function getTokenScopes(): string { return $this->token_scopes; } public function setRevoked(bool $revoked): self { $this->revoked = $revoked; return $this; } public function getRevoked(): bool { return $this->revoked; } public function setCreated(DateTimeInterface $created): self { $this->created = $created; return $this; } public function getCreated(): DateTimeInterface { return $this->created; } // @codeCoverageIgnoreEnd // }}} Autocode /** * @return null|string */ public function getRedirectUri() { return (new Repository\Client)->getClientEntity($this->getClientId())->getRedirectUri(); } /** * @param string $uri */ public function setRedirectUri($uri) { /** @var Client $client */ $client = (new Repository\Client)->getClientEntity($this->getClientId()); $client->setRedirectUris($uri); } public static function schemaDef(): array { return parent::tokenSchema('oauth2_auth_code'); } }