Nextcloud password generator got lost. Put it back

This commit is contained in:
the-djmaze 2022-10-25 11:40:04 +02:00
parent a197378b7c
commit e183764e51
2 changed files with 11 additions and 1 deletions

View file

@ -26,10 +26,12 @@ class SnappyMailHelper
$oConfig = \RainLoop\Api::Config();
$bSave = false;
if (!$oConfig->Get('webmail', 'app_path')) {
$oConfig->Set('webmail', 'app_path', \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app/');
$bSave = true;
}
if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) {
\SnappyMail\Repository::installPackage('plugin', 'nextcloud');
$oConfig->Set('plugins', 'enable', true);
@ -40,6 +42,14 @@ class SnappyMailHelper
$bSave = true;
}
$sPassword = $oConfig->Get('security', 'admin_password');
if ('12345' == $sPassword || !$sPassword) {
$sPassword = \substr(\base64_encode(\random_bytes(16)), 0, 12);
$oConfig->SetPassword($sPassword);
\RainLoop\Utils::saveFile(APP_PRIVATE_DATA . 'admin_password.txt', $sPassword . "\n");
$bSave = true;
}
$bSave && $oConfig->Save();
}