Move generating admin_password RainLoop\Actions to RainLoop\ActionsAdmin

This commit is contained in:
the-djmaze 2022-05-08 11:03:39 +02:00
parent 944b4ae856
commit fb95174f67
2 changed files with 15 additions and 12 deletions

View file

@ -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);

View file

@ -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);