Skip to content

Commit

Permalink
Merge pull request #70 from RobvH/master
Browse files Browse the repository at this point in the history
Removed race-condition in token handling
  • Loading branch information
omniphx committed Nov 21, 2015
2 parents d34681e + e2abcb4 commit cda6876
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
composer.phar
composer.lock
.DS_Store
/.idea
/src/config/local
/src/config/production
mm.log
Expand Down
15 changes: 13 additions & 2 deletions src/Omniphx/Forrest/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ abstract class Client
*/
protected $storage;

/**
* Token data.
*
* @var array
*/
protected $tokenData;

/**
* Reqeust headers.
*
Expand Down Expand Up @@ -535,7 +542,11 @@ public function __call($name, $arguments)
*/
public function getTokenData()
{
return $this->storage->getTokenData();
if (empty($this->tokenData)) {
$this->tokenData = $this->storage->getTokenData();
}

return $this->tokenData;
}

/**
Expand Down Expand Up @@ -647,7 +658,7 @@ private function setHeaders(array $options)
{
$format = $options['format'];

$authToken = $this->storage->getTokenData();
$authToken = $this->getTokenData();

$accessToken = $authToken['access_token'];
$tokenType = $authToken['token_type'];
Expand Down

0 comments on commit cda6876

Please sign in to comment.