diff --git a/php/public/index.php b/php/public/index.php index 29c467d4..a1a8c189 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -89,9 +89,13 @@ $app->get('/containers', function ($request, $response, $args) use ($container) 'last_backup_time' => $configurationManager->GetLastBackupTime(), ]); })->setName('profile'); -$app->get('/login', function ($request, $response, $args) { +$app->get('/login', function ($request, $response, $args) use ($container) { $view = Twig::fromRequest($request); - return $view->render($response, 'login.twig'); + /** @var \AIO\Docker\DockerActionManager $dockerActionManger */ + $dockerActionManger = $container->get(\AIO\Docker\DockerActionManager::class); + return $view->render($response, 'login.twig', [ + 'is_login_allowed' => $dockerActionManger->isLoginAllowed(), + ]); }); $app->get('/setup', function ($request, $response, $args) use ($container) { $view = Twig::fromRequest($request); diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 9a424108..79702cd9 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -507,4 +507,13 @@ class DockerActionManager return -1; } } + + public function isLoginAllowed() : bool { + $id = 'nextcloud-aio-apache'; + $apacheContainer = $this->containerDefinitionFetcher->GetContainerById($id); + if ($this->GetContainerStartingState($apacheContainer) instanceof RunningState) { + return false; + } + return true; + } } diff --git a/php/templates/login.twig b/php/templates/login.twig index 06b875ea..f9f7564a 100644 --- a/php/templates/login.twig +++ b/php/templates/login.twig @@ -5,13 +5,18 @@
Log in using your Nextcloud AIO password. If you don't have it, you can also use the automatic login from your Nextcloud.
- + {% if is_login_allowed == true %} +Log in using your Nextcloud AIO password.
+ + {% else %} +The login is blocked since Nextcloud is running. Please use the automatic login from your Nextcloud.
+ You can unblock the login by running 'sudo docker stop nextcloud-aio-apache'.