Throw MissingAccessTokenException in the Resource server when no token exists

This commit is contained in:
Woody Gilk 2014-05-31 15:34:12 -05:00
parent 4486b7120f
commit d7c1c50269
3 changed files with 25 additions and 4 deletions

View File

@ -0,0 +1,20 @@
<?php
/**
* OAuth 2.0 Missing Access Token Exception
*
* @package php-loep/oauth2-server
* @author Woody Gilk <woody@shadowhand.me>
* @copyright Copyright (c) 2014 PHP League of Extraordinary Packages
* @license http://mit-license.org/
* @link http://github.com/php-loep/oauth2-server
*/
namespace League\OAuth2\Server\Exception;
/**
* MissingAccessToken Exception
*/
class MissingAccessTokenException extends OAuth2Exception
{
}

View File

@ -4,7 +4,8 @@
* *
* @package php-loep/oauth2-server * @package php-loep/oauth2-server
* @author Alex Bilbie <hello@alexbilbie.com> * @author Alex Bilbie <hello@alexbilbie.com>
* @copyright Copyright (c) 2013 PHP League of Extraordinary Packages * @author Woody Gilk <woody@shadowhand.me>
* @copyright Copyright (c) 2013-2014 PHP League of Extraordinary Packages
* @license http://mit-license.org/ * @license http://mit-license.org/
* @link http://github.com/php-loep/oauth2-server * @link http://github.com/php-loep/oauth2-server
*/ */
@ -274,7 +275,7 @@ class Resource
} }
if (empty($accessToken)) { if (empty($accessToken)) {
throw new Exception\InvalidAccessTokenException('Access token is missing'); throw new Exception\MissingAccessTokenException('Access token is missing');
} }
return $accessToken; return $accessToken;

View File

@ -66,7 +66,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
} }
/** /**
* @expectedException League\OAuth2\Server\Exception\InvalidAccessTokenException * @expectedException League\OAuth2\Server\Exception\MissingAccessTokenException
*/ */
public function test_determineAccessToken_missingToken() public function test_determineAccessToken_missingToken()
{ {
@ -84,7 +84,7 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
} }
/** /**
* @expectedException League\OAuth2\Server\Exception\InvalidAccessTokenException * @expectedException League\OAuth2\Server\Exception\MissingAccessTokenException
*/ */
public function test_determineAccessToken_brokenCurlRequest() public function test_determineAccessToken_brokenCurlRequest()
{ {