mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 22:46:55 +00:00
Fixes https://github.com/nextcloud/all-in-one/issues/4 Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
32 lines
822 B
PHP
32 lines
822 B
PHP
<?php
|
|
|
|
namespace AIO\Data;
|
|
|
|
use AIO\Auth\PasswordGenerator;
|
|
|
|
class Setup
|
|
{
|
|
private PasswordGenerator $passwordGenerator;
|
|
private ConfigurationManager $configurationManager;
|
|
|
|
public function __construct(
|
|
PasswordGenerator $passwordGenerator,
|
|
ConfigurationManager $configurationManager) {
|
|
$this->passwordGenerator = $passwordGenerator;
|
|
$this->configurationManager = $configurationManager;
|
|
}
|
|
|
|
public function Setup() : string {
|
|
if(!$this->CanBeInstalled()) {
|
|
return '';
|
|
}
|
|
|
|
$password = $this->passwordGenerator->GeneratePassword(8);
|
|
$this->configurationManager->SetPassword($password);
|
|
return $password;
|
|
}
|
|
|
|
public function CanBeInstalled() : bool {
|
|
return !file_exists(DataConst::GetConfigFile());
|
|
}
|
|
}
|