mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-07 06:18:00 +00:00
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:
commit
94e56757dd
4 changed files with 33 additions and 10 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue