Skip to content

Commit

Permalink
Fix error when "parameter" option is disabled and header not set.
Browse files Browse the repository at this point in the history
Closes #47
  • Loading branch information
ADmad committed Jan 7, 2017
1 parent 6e0235e commit 5d26893
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Auth/JwtAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ public function getToken($request = null)
}

if (!empty($this->_config['parameter'])) {
$token = $request->query($this->_config['parameter']);
$this->_token = $request->query($this->_config['parameter']);
}

return $this->_token = $token;
return $this->_token;
}

/**
Expand Down
18 changes: 18 additions & 0 deletions tests/TestCase/Auth/JwtAuthenticateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ public function testAuthenticateTokenHeader()
$this->assertFalse($result);
}

/**
* test authenticate no token present in header "parameter" option disabled.
*
* @return void
*/
public function testAuthenticateNoHeaderWithParameterDisabled()
{
$request = new Request('posts/index');

$this->auth = new JwtAuthenticate($this->Registry, [
'userModel' => 'Users',
'parameter' => false
]);

$result = $this->auth->getUser($request, $this->response);
$this->assertFalse($result);
}

/**
* test returning payload without querying database.
*
Expand Down

0 comments on commit 5d26893

Please sign in to comment.