Skip to content

Commit 6c982d3

Browse files
committed
Introduce removeAuthorization() in OAuthClient
This method can be used for deleting an authorization record if it is not needed anymore. Resolves #20
1 parent 38a1d17 commit 6c982d3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Classes/OAuthClient.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,22 @@ public function getAuthorization(string $authorizationId): ?Authorization
403403
return ($oAuthToken instanceof Authorization) ? $oAuthToken : null;
404404
}
405405

406+
/**
407+
* Removes the specified Authorization record
408+
*
409+
* @param string $authorizationId
410+
* @return void
411+
*/
412+
public function removeAuthorization(string $authorizationId): void
413+
{
414+
$existingAuthorization = $this->getAuthorization($authorizationId);
415+
if ($existingAuthorization !== null) {
416+
$this->entityManager->remove($existingAuthorization);
417+
$this->entityManager->flush();
418+
$this->logger->debug(sprintf('OAuth (%s): Removed authorization id %s', $this->getServiceType(), $authorizationId), LogEnvironment::fromMethodName(__METHOD__));
419+
}
420+
}
421+
406422
/**
407423
* Returns a prepared request to an OAuth 2.0 service provider using Bearer token authentication
408424
*

0 commit comments

Comments
 (0)