Skip to content

Commit

Permalink
Merge pull request #8 from progammer-rkt/fix/Make-Sure-Customer-Token…
Browse files Browse the repository at this point in the history
…-Always-Created-Fresh

Make Sure Existing Token Is Removed Prior to Create a New Token
  • Loading branch information
wigman committed May 25, 2021
2 parents fef1e0f + a4c6e2d commit d68a182
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/CustomerData/CustomerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ class CustomerPlugin
* @var TokenModelFactory
*/
private $tokenModelFactory;

/**
* @var OauthHelper
*/
private $oauthHelper;

/**
* @var DateTime
*/
private $dateTime;

/**
* @var Date
*/
Expand Down Expand Up @@ -108,6 +108,13 @@ public function afterGetSectionData(Customer $subject, array $result)
$token = $tokenModel->loadByCustomerId($customerId);

if (!$token->getId() || $token->getRevoked() || $this->isTokenExpired($token)) {
// if there exist an entry in oauth_token table for the customer, then
// remove it before attempting createCustomerToken
if ($token->getId()) {
$token->delete();
$tokenModel = $this->tokenModelFactory->create();
}

$token = $tokenModel->createCustomerToken($customerId);
}

Expand Down

0 comments on commit d68a182

Please sign in to comment.