Skip to content

Commit

Permalink
Merge pull request #144 from seegno/support/otp-header
Browse files Browse the repository at this point in the history
Update OTP header
  • Loading branch information
nunorafaelrocha authored Dec 15, 2016
2 parents faff022 + 2f3a10c commit 9932747
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Uphold/HttpClient/Handler/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function onRequestException(RequestException $e)
}

if (401 === $statusCode) {
$otp = (string) $response->getHeader('X-Bitreserve-OTP');
$otp = (string) $response->getHeader('OTP-Token');

if ('required' === $otp) {
$description = 'Two factor authentication is enabled on this account';
Expand Down
2 changes: 1 addition & 1 deletion lib/Uphold/UpholdClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function createToken($login, $password, $description, $otp = null)
{
$headers = array_merge($this->getDefaultHeaders(), array(
'Authorization' => sprintf('Basic %s', base64_encode(sprintf('%s:%s', $login, $password))),
'X-Bitreserve-OTP' => $otp,
'OTP-Token' => $otp,
));

$response = $this->post('/me/tokens',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function shouldThrowAuthenticationRequiredExceptionWhenStatusCodeIs401()
$response
->expects($this->once())
->method('getHeader')
->with('X-Bitreserve-OTP')
->with('OTP-Token')
->will($this->returnValue(null))
;

Expand All @@ -156,7 +156,7 @@ public function shouldThrowTwoFactorAuthenticationRequiredExceptionWhenStatusCod
$response
->expects($this->once())
->method('getHeader')
->with('X-Bitreserve-OTP')
->with('OTP-Token')
->will($this->returnValue('required'))
;

Expand Down
4 changes: 2 additions & 2 deletions test/Uphold/Tests/Unit/UpholdClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function shouldCreateToken()

$headers = array(
'Authorization' => sprintf('Basic %s', base64_encode(sprintf('%s:%s', $login, $password))),
'X-Bitreserve-OTP' => $otp,
'OTP-Token' => $otp,
);

$data = array('foo' => 'bar');
Expand Down Expand Up @@ -504,7 +504,7 @@ public function shouldCreateTokenWithOTP()

$headers = array(
'Authorization' => sprintf('Basic %s', base64_encode(sprintf('%s:%s', $login, $password))),
'X-Bitreserve-OTP' => $otp,
'OTP-Token' => $otp,
);

$data = array('foo' => 'bar');
Expand Down

0 comments on commit 9932747

Please sign in to comment.