diff --git a/src/DI/SimpleHttpAuthExtension.php b/src/DI/SimpleHttpAuthExtension.php index cee0dcf..4a45ead 100644 --- a/src/DI/SimpleHttpAuthExtension.php +++ b/src/DI/SimpleHttpAuthExtension.php @@ -32,7 +32,8 @@ public function loadConfiguration() ->setArguments([ $config['username'], $config['password'], - $config['presenters'] + $config['presenters'], + $builder->parameters['consoleMode'], ]); } diff --git a/src/SimpleHttpAuth.php b/src/SimpleHttpAuth.php index 98ebd39..b001abc 100644 --- a/src/SimpleHttpAuth.php +++ b/src/SimpleHttpAuth.php @@ -33,6 +33,7 @@ class SimpleHttpAuth extends Nette\DI\CompilerExtension * @param string $username * @param string $password * @param array $presenters If array of presenters is empty, accept all + * @param bool $isConsole * @param Nette\Application\IRouter $router * @param Nette\Http\IRequest $httpRequest * @param Nette\Http\IResponse $httpResponse @@ -41,6 +42,7 @@ public function __construct( $username, $password, $presenters, + $isConsole, Nette\Application\IRouter $router, Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse, @@ -50,6 +52,10 @@ public function __construct( $this->httpResponse = $httpResponse; $this->exit_on_bad_credentials = $exit_on_bad_credentials; + if ($isConsole === TRUE) { + return; + } + if (empty($username) && empty($password)) { return; } diff --git a/tests/cases/SimpleHttpAuthTest.phpt b/tests/cases/SimpleHttpAuthTest.phpt index 9828b11..c981ea2 100644 --- a/tests/cases/SimpleHttpAuthTest.phpt +++ b/tests/cases/SimpleHttpAuthTest.phpt @@ -86,6 +86,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase 'admin', '1234567890', ['Front:Secured', 'Front:AnotherSecured'], + FALSE, $this->router, $this->request, $this->response, @@ -111,6 +112,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase 'admin', '1234567890', ['Front:Secured', 'Front:AnotherSecured'], + FALSE, $this->router, $this->request, $this->response, @@ -136,6 +138,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase 'admin', '1234567890', ['Front:Secured', 'Front:AnotherSecured'], + FALSE, $this->router, $this->request, $this->response, @@ -161,6 +164,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase '', '', [], + FALSE, $this->router, $this->request, $this->response,