Skip to content

Commit

Permalink
Disable authentication in consoleMode
Browse files Browse the repository at this point in the history
  • Loading branch information
RiKap committed Feb 21, 2017
1 parent 0e9f32b commit f1a24c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/DI/SimpleHttpAuthExtension.php
Expand Up @@ -32,7 +32,8 @@ public function loadConfiguration()
->setArguments([
$config['username'],
$config['password'],
$config['presenters']
$config['presenters'],
$builder->parameters['consoleMode'],
]);
}

Expand Down
6 changes: 6 additions & 0 deletions src/SimpleHttpAuth.php
Expand Up @@ -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
Expand All @@ -41,6 +42,7 @@ public function __construct(
$username,
$password,
$presenters,
$isConsole,
Nette\Application\IRouter $router,
Nette\Http\IRequest $httpRequest,
Nette\Http\IResponse $httpResponse,
Expand All @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/cases/SimpleHttpAuthTest.phpt
Expand Up @@ -86,6 +86,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase
'admin',
'1234567890',
['Front:Secured', 'Front:AnotherSecured'],
FALSE,
$this->router,
$this->request,
$this->response,
Expand All @@ -111,6 +112,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase
'admin',
'1234567890',
['Front:Secured', 'Front:AnotherSecured'],
FALSE,
$this->router,
$this->request,
$this->response,
Expand All @@ -136,6 +138,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase
'admin',
'1234567890',
['Front:Secured', 'Front:AnotherSecured'],
FALSE,
$this->router,
$this->request,
$this->response,
Expand All @@ -161,6 +164,7 @@ final class SimpleHttpAuthTest extends Tester\TestCase
'',
'',
[],
FALSE,
$this->router,
$this->request,
$this->response,
Expand Down

0 comments on commit f1a24c7

Please sign in to comment.