all-in-one/php/src/Data/Setup.php
Lukas Reschke 535c9c2895 Increase length of passphrase to 8 words
Fixes https://github.com/nextcloud/all-in-one/issues/4

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
2021-11-30 13:04:06 +01:00

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());
}
}