mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-26 06:59:49 +05:30
parent
ded7c1ed47
commit
d8ece093d5
@ -273,6 +273,19 @@ class OAuthServerException extends \Exception
|
|||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the exception includes a redirect, since
|
||||||
|
* getHttpStatusCode() doesn't return a 302 when there's a
|
||||||
|
* redirect enabled. This helps when you want to override local
|
||||||
|
* error pages but want to let redirects through.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasRedirect()
|
||||||
|
{
|
||||||
|
return $this->redirectUri !== null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HTTP status code to send when the exceptions is output.
|
* Returns the HTTP status code to send when the exceptions is output.
|
||||||
*
|
*
|
||||||
|
17
tests/ExceptionTest.php
Normal file
17
tests/ExceptionTest.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LeagueTests\Utils;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
|
|
||||||
|
class ExceptionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testHasRedirect()
|
||||||
|
{
|
||||||
|
$exceptionWithoutRedirect = OAuthServerException::accessDenied('Some hint');
|
||||||
|
$this->assertFalse($exceptionWithoutRedirect->hasRedirect());
|
||||||
|
|
||||||
|
$exceptionWithRedirect = OAuthServerException::accessDenied('some hint', 'https://example.com/error');
|
||||||
|
$this->assertTrue($exceptionWithRedirect->hasRedirect());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user