Merge pull request #94 from nextcloud/enh/3/disable-login-if-nextcloud-is-running

disable login if Nextcloud is running
This commit is contained in:
Simon L 2022-01-14 12:09:14 +01:00 committed by GitHub
commit 94e56757dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 10 deletions

View file

@ -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);

View file

@ -517,4 +517,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;
}
}