mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 21:19:46 +05:30
Added method to get the exception type
This commit is contained in:
parent
9f6bd64100
commit
92d9435bba
@ -67,7 +67,7 @@ class AuthServer
|
|||||||
* Exception error codes
|
* Exception error codes
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $exceptionCodes = array(
|
protected static $exceptionCodes = array(
|
||||||
0 => 'invalid_request',
|
0 => 'invalid_request',
|
||||||
1 => 'unauthorized_client',
|
1 => 'unauthorized_client',
|
||||||
2 => 'access_denied',
|
2 => 'access_denied',
|
||||||
@ -110,6 +110,17 @@ class AuthServer
|
|||||||
return self::$exceptionMessages[$error];
|
return self::$exceptionMessages[$error];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an exception code
|
||||||
|
*
|
||||||
|
* @param integer $code The exception code
|
||||||
|
* @return string The exception code type
|
||||||
|
*/
|
||||||
|
public static function getExceptionType($code = 0)
|
||||||
|
{
|
||||||
|
return self::$exceptionCodes[$code];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new OAuth2 authentication server
|
* Create a new OAuth2 authentication server
|
||||||
*
|
*
|
||||||
|
@ -45,6 +45,11 @@ class Authentication_Server_test extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($v['access_denied'], $m);
|
$this->assertEquals($v['access_denied'], $m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_getExceptionCode()
|
||||||
|
{
|
||||||
|
$this->assertEquals('access_denied', OAuth2\AuthServer::getExceptionType(2));
|
||||||
|
}
|
||||||
|
|
||||||
public function test_hasGrantType()
|
public function test_hasGrantType()
|
||||||
{
|
{
|
||||||
$this->assertFalse(OAuth2\AuthServer::hasGrantType('test'));
|
$this->assertFalse(OAuth2\AuthServer::hasGrantType('test'));
|
||||||
|
Loading…
Reference in New Issue
Block a user