diff --git a/src/Exception/OAuthServerException.php b/src/Exception/OAuthServerException.php index 6ffa0fb1..30007be7 100644 --- a/src/Exception/OAuthServerException.php +++ b/src/Exception/OAuthServerException.php @@ -273,6 +273,19 @@ class OAuthServerException extends \Exception 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. * diff --git a/tests/ExceptionTest.php b/tests/ExceptionTest.php new file mode 100644 index 00000000..2d77118e --- /dev/null +++ b/tests/ExceptionTest.php @@ -0,0 +1,17 @@ +assertFalse($exceptionWithoutRedirect->hasRedirect()); + + $exceptionWithRedirect = OAuthServerException::accessDenied('some hint', 'https://example.com/error'); + $this->assertTrue($exceptionWithRedirect->hasRedirect()); + } +} \ No newline at end of file