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

@ -42,7 +42,7 @@ class AdminSettings implements ISettings
} }
$parameters['snappymail-admin-password'] = $sPassword; $parameters['snappymail-admin-password'] = $sPassword;
$parameters['can-import-rainloop'] = \is_dir( $parameters['can-import-rainloop'] = $sPassword && \is_dir(
\rtrim(\trim(\OC::$server->getSystemConfig()->getValue('datadirectory', '')), '\\/') \rtrim(\trim(\OC::$server->getSystemConfig()->getValue('datadirectory', '')), '\\/')
. '/rainloop-storage' . '/rainloop-storage'
); );

View file

@ -26,10 +26,12 @@ class SnappyMailHelper
$oConfig = \RainLoop\Api::Config(); $oConfig = \RainLoop\Api::Config();
$bSave = false; $bSave = false;
if (!$oConfig->Get('webmail', 'app_path')) { if (!$oConfig->Get('webmail', 'app_path')) {
$oConfig->Set('webmail', 'app_path', \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app/'); $oConfig->Set('webmail', 'app_path', \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app/');
$bSave = true; $bSave = true;
} }
if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) { if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) {
\SnappyMail\Repository::installPackage('plugin', 'nextcloud'); \SnappyMail\Repository::installPackage('plugin', 'nextcloud');
$oConfig->Set('plugins', 'enable', true); $oConfig->Set('plugins', 'enable', true);
@ -40,6 +42,14 @@ class SnappyMailHelper
$bSave = true; $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(); $bSave && $oConfig->Save();
} }