Skip to content

Commit

Permalink
Remove unnecessary repository functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sephster committed Mar 21, 2024
1 parent 67284de commit e8b5669
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 26 deletions.
17 changes: 3 additions & 14 deletions examples/src/Repositories/DeviceCodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public function getDeviceCodeEntityByDeviceCode($deviceCode): ?DeviceCodeEntityI
$deviceCodeEntity = new DeviceCodeEntity();

$deviceCodeEntity->setIdentifier($deviceCode);
$deviceCodeEntity->setExpiryDateTime((new DateTimeImmutable)->setTimestamp($this->getDeviceCodeExpiryTime($deviceCode)));
$deviceCodeEntity->setExpiryDateTime(new DateTimeImmutable('now +1 hour'));
$deviceCodeEntity->setClient($clientEntity);

// TODO: Check if this is still true as it seems we need to set userapproved
// The user identifier should be set when the user authenticates on the OAuth server
// The user identifier should be set when the user authenticates on the
// OAuth server, along with whether they approved the request
$deviceCodeEntity->setUserApproved(true);
$deviceCodeEntity->setUserIdentifier(1);

Expand All @@ -71,15 +71,4 @@ public function isDeviceCodeRevoked($codeId): bool
{
return false;
}

// TODO: This should probably return a datetimeimmutable object to match the setter
public function getDeviceCodeExpiryTime(string $codeId): int
{
return (new DateTimeImmutable('now + 1 hour'))->getTimestamp();
}

public function getDeviceCodeClientId(string $codeId): string
{
// Some logic to get the client ID of the device code
}
}
1 change: 0 additions & 1 deletion examples/src/Repositories/ScopeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function getScopeEntityByIdentifier($scopeIdentifier): ?ScopeEntityInterf
return $scope;
}

// TODO: Check why I have added authCodeId here
/**
* {@inheritdoc}
*/
Expand Down
1 change: 0 additions & 1 deletion src/Grant/DeviceCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public function respondToAccessTokenRequest(
$scopes = $this->validateScopes($this->getRequestParameter('scope', $request, $this->defaultScope));
$deviceCodeEntity = $this->validateDeviceCode($request, $client);

// TODO: This should be set on the repository, not the entity
$deviceCodeEntity->setLastPolledAt(new DateTimeImmutable());
$this->deviceCodeRepository->persistDeviceCode($deviceCodeEntity);

Expand Down
10 changes: 0 additions & 10 deletions src/Repositories/DeviceCodeRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,4 @@ public function revokeDeviceCode(string $codeId): void;
* @return bool Return true if this code has been revoked
*/
public function isDeviceCodeRevoked(string $codeId): bool;

/**
* Get the expiry time of the device code.
*/
public function getDeviceCodeExpiryTime(string $codeId): int;

/**
* Get the client ID of the device code.
*/
public function getDeviceCodeClientId(string $codeId): string;
}

0 comments on commit e8b5669

Please sign in to comment.