Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Repository/Pdo/AccessTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEnt
':user_id' => $accessTokenEntity->getUserIdentifier(),
':client_id' => $accessTokenEntity->getClient()->getIdentifier(),
':scopes' => $this->scopesToString($accessTokenEntity->getScopes()),
':revoked' => false,
':expires_at' => $accessTokenEntity->getExpiryDateTime()->getTimestamp()
':revoked' => 0,
':expires_at' => date(
'Y-m-d H:i:s',
$accessTokenEntity->getExpiryDateTime()->getTimestamp()
),
];

if (false === $sth->execute($params)) {
Expand All @@ -87,7 +90,7 @@ public function revokeAccessToken($tokenId)
$sth = $this->pdo->prepare(
'UPDATE oauth_access_tokens SET revoked=:revoked WHERE id = :tokenId'
);
$sth->bindValue(':revoked', true);
$sth->bindValue(':revoked', 0);
$sth->bindParam(':tokenId', $tokenId);

$sth->execute();
Expand Down
12 changes: 9 additions & 3 deletions src/Repository/Pdo/AuthCodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity)
$sth->bindValue(':user_id', $authCodeEntity->getUserIdentifier());
$sth->bindValue(':client_id', $authCodeEntity->getClient()->getIdentifier());
$sth->bindValue(':scopes', $this->scopesToString($authCodeEntity->getScopes()));
$sth->bindValue(':revoked', false);
$sth->bindValue(':expires_at', $authCodeEntity->getExpiryDateTime()->getTimestamp());
$sth->bindValue(':revoked', 0);
$sth->bindValue(
':expires_at',
date(
'Y-m-d H:i:s',
$authCodeEntity->getExpiryDateTime()->getTimestamp()
)
);

if (false === $sth->execute()) {
throw UniqueTokenIdentifierConstraintViolationException::create();
Expand All @@ -55,7 +61,7 @@ public function revokeAuthCode($codeId)
$sth = $this->pdo->prepare(
'UPDATE oauth_auth_codes SET revoked=:revoked WHERE id = :codeId'
);
$sth->bindValue(':revoked', true);
$sth->bindValue(':revoked', 1);
$sth->bindParam(':codeId', $codeId);

$sth->execute();
Expand Down
12 changes: 9 additions & 3 deletions src/Repository/Pdo/RefreshTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshToken

$sth->bindValue(':id', $refreshTokenEntity->getIdentifier());
$sth->bindValue(':access_token_id', $refreshTokenEntity->getAccessToken()->getIdentifier());
$sth->bindValue(':revoked', false);
$sth->bindValue(':expires_at', $refreshTokenEntity->getExpiryDateTime()->getTimestamp());
$sth->bindValue(':revoked', 0);
$sth->bindValue(
':expires_at',
date(
'Y-m-d H:i:s',
$refreshTokenEntity->getExpiryDateTime()->getTimestamp()
)
);

if (false === $sth->execute()) {
throw UniqueTokenIdentifierConstraintViolationException::create();
Expand All @@ -44,7 +50,7 @@ public function revokeRefreshToken($tokenId)
$sth = $this->pdo->prepare(
'UPDATE oauth_refresh_tokens SET revoked=:revoked WHERE id = :tokenId'
);
$sth->bindValue(':revoked', true);
$sth->bindValue(':revoked', 1);
$sth->bindParam(':tokenId', $tokenId);

$sth->execute();
Expand Down
4 changes: 2 additions & 2 deletions test/Repository/Pdo/AccessTokenRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function testPersistNewAccessTokenRaisesExceptionWhenStatementExecutionFa
':user_id' => 'user_id',
':client_id' => 'client_id',
':scopes' => 'authentication',
':revoked' => false,
':expires_at' => $time,
':revoked' => 0,
':expires_at' => date('Y-m-d H:i:s', $time),
])
->willReturn(false);

Expand Down
5 changes: 3 additions & 2 deletions test/Repository/Pdo/AuthCodeRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public function testPeristNewAuthCodeRaisesExceptionWhenStatementExecutionFails(
$statement->bindValue(':user_id', 'user_id')->shouldBeCalled();
$statement->bindValue(':client_id', 'client_id')->shouldBeCalled();
$statement->bindValue(':scopes', 'authentication')->shouldBeCalled();
$statement->bindValue(':revoked', false)->shouldBeCalled();
$statement->bindValue(':expires_at', $time)->shouldBeCalled();
$statement->bindValue(':revoked', 0)->shouldBeCalled();
$statement->bindValue(':expires_at', date('Y-m-d H:i:s', $time))
->shouldBeCalled();
$statement->execute()->willReturn(false);

$this->pdo
Expand Down
5 changes: 3 additions & 2 deletions test/Repository/Pdo/RefreshTokenRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public function testPersistNewRefreshTokenRaisesExceptionWhenStatementExecutionF
$statement = $this->prophesize(PDOStatement::class);
$statement->bindValue(':id', 'id')->shouldBeCalled();
$statement->bindValue(':access_token_id', 'access_token_id')->shouldBeCalled();
$statement->bindValue(':revoked', false)->shouldBeCalled();
$statement->bindValue(':expires_at', $time)->shouldBeCalled();
$statement->bindValue(':revoked', 0)->shouldBeCalled();
$statement->bindValue(':expires_at', date('Y-m-d H:i:s', $time))
->shouldBeCalled();
$statement->execute()->willReturn(false)->shouldBeCalled();

$this->pdo
Expand Down