From 1b005d39e7ea0df6c540ffead575cdfad132ff9e Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Wed, 30 Oct 2024 20:25:06 +0330 Subject: [PATCH] revert example changes --- examples/src/Repositories/DeviceCodeRepository.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/src/Repositories/DeviceCodeRepository.php b/examples/src/Repositories/DeviceCodeRepository.php index 055d6f204..9495c9a15 100644 --- a/examples/src/Repositories/DeviceCodeRepository.php +++ b/examples/src/Repositories/DeviceCodeRepository.php @@ -15,6 +15,7 @@ use DateTimeImmutable; use League\OAuth2\Server\Entities\DeviceCodeEntityInterface; use League\OAuth2\Server\Repositories\DeviceCodeRepositoryInterface; +use OAuth2ServerExamples\Entities\ClientEntity; use OAuth2ServerExamples\Entities\DeviceCodeEntity; class DeviceCodeRepository implements DeviceCodeRepositoryInterface @@ -38,12 +39,16 @@ public function persistDeviceCode(DeviceCodeEntityInterface $deviceCodeEntity): /** * {@inheritdoc} */ - public function getDeviceCodeEntityByDeviceCode(string $deviceCode): ?DeviceCodeEntityInterface + public function getDeviceCodeEntityByDeviceCode($deviceCode): ?DeviceCodeEntityInterface { + $clientEntity = new ClientEntity(); + $clientEntity->setIdentifier('myawesomeapp'); + $deviceCodeEntity = new DeviceCodeEntity(); - $deviceCodeEntity->setLastPolledAt(new DateTimeImmutable()); - $deviceCodeEntity->setInterval(5); + $deviceCodeEntity->setIdentifier($deviceCode); + $deviceCodeEntity->setExpiryDateTime(new DateTimeImmutable('now +1 hour')); + $deviceCodeEntity->setClient($clientEntity); // The user identifier should be set when the user authenticates on the // OAuth server, along with whether they approved the request