From fb95174f6799bf652c65afb9c088615da4a44361 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 8 May 2022 11:03:39 +0200 Subject: [PATCH] Move generating admin_password RainLoop\Actions to RainLoop\ActionsAdmin --- .../v/0.0.0/app/libraries/RainLoop/Actions.php | 12 ------------ .../0.0.0/app/libraries/RainLoop/ActionsAdmin.php | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index 0f5d98e3b..450a052ee 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -748,18 +748,6 @@ class Actions 'UserBackgroundHash' => '' ); - $oSettings = null; - - $passfile = APP_PRIVATE_DATA.'admin_password.txt'; - $sPassword = $oConfig->Get('security', 'admin_password', ''); - if (!$sPassword) { - $sPassword = \substr(\base64_encode(\random_bytes(16)), 0, 12); - Utils::saveFile($passfile, $sPassword . "\n"); -// \chmod($passfile, 0600); - $oConfig->SetPassword($sPassword); - $oConfig->Save(); - } - $sLanguage = $oConfig->Get('webmail', 'language', 'en'); $UserLanguageRaw = $this->detectUserLanguage($bAdmin); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php index 95d7b9cc1..6d37e5a24 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php @@ -660,6 +660,21 @@ class ActionsAdmin extends Actions return $this->DefaultResponse(__FUNCTION__, true); } + public function AppData(bool $bAdmin): array + { + $oConfig = $this->oConfig; + $passfile = APP_PRIVATE_DATA.'admin_password.txt'; + $sPassword = $oConfig->Get('security', 'admin_password', ''); + if (!$sPassword) { + $sPassword = \substr(\base64_encode(\random_bytes(16)), 0, 12); + Utils::saveFile($passfile, $sPassword . "\n"); +// \chmod($passfile, 0600); + $oConfig->SetPassword($sPassword); + $oConfig->Save(); + } + return parent::AppData($bAdmin); + } + private function setAdminAuthToken(string $sToken) : void { Utils::SetCookie(static::$AUTH_ADMIN_TOKEN_KEY, $sToken, 0);