diff --git a/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php b/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php index 5b4294824..14be42c92 100644 --- a/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php +++ b/integrations/nextcloud/snappymail/lib/Settings/AdminSettings.php @@ -42,7 +42,7 @@ class AdminSettings implements ISettings } $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', '')), '\\/') . '/rainloop-storage' ); diff --git a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php index 60e8227ed..95de7aba8 100644 --- a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php +++ b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php @@ -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(); }