Skip to content

Commit

Permalink
Added check for token NULL value before saving following 401
Browse files Browse the repository at this point in the history
If the token header is NULL (as it would be for a 401) and this is saved, the subsequent authorisation attempt is impossible since the existing token has been overwritten.
  • Loading branch information
croxton committed Sep 11, 2013
1 parent f01752b commit b8f4e18
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/YDD/Vebra/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ public function execute($url, $secondAttempt = false)
$tokenResponse = $this->messageFactory->createResponse();
$this->client->send($tokenRequest, $tokenResponse);

// save the token
// if we have a token, save it
$token = $tokenResponse->getHeader('Token');
$this->tokenStorage->setToken(trim($token));
if ( ! is_null($token)) {
$this->tokenStorage->setToken(trim($token));
}

// try again
return $this->execute($url, true);
Expand Down

0 comments on commit b8f4e18

Please sign in to comment.