diff --git a/php/src/Controller/LoginController.php b/php/src/Controller/LoginController.php index c917115c..aaab2952 100644 --- a/php/src/Controller/LoginController.php +++ b/php/src/Controller/LoginController.php @@ -12,12 +12,17 @@ use Psr\Http\Message\ServerRequestInterface as Request; class LoginController { private AuthManager $authManager; + private DockerActionManager $dockerActionManager; - public function __construct(AuthManager $authManager) { + public function __construct(AuthManager $authManager, DockerActionManager $dockerActionManager) { $this->authManager = $authManager; + $this->dockerActionManager = $dockerActionManager; } public function TryLogin(Request $request, Response $response, $args) : Response { + if (!$this->dockerActionManager->isLoginAllowed()) { + return $response->withHeader('Location', '/')->withStatus(302); + } $password = $request->getParsedBody()['password']; if($this->authManager->CheckCredentials($password)) { $this->authManager->SetAuthState(true);