From b8f4e18a652a6b9129e3492fadcefbf7c867f36c Mon Sep 17 00:00:00 2001 From: Mark Croxton Date: Wed, 11 Sep 2013 11:09:33 +0100 Subject: [PATCH] Added check for token NULL value before saving following 401 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. --- lib/YDD/Vebra/API.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/YDD/Vebra/API.php b/lib/YDD/Vebra/API.php index fbe5e2b..d9ec8c1 100644 --- a/lib/YDD/Vebra/API.php +++ b/lib/YDD/Vebra/API.php @@ -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);