mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Resolve #389
This commit is contained in:
parent
824311937a
commit
b267458f7e
3 changed files with 11 additions and 21 deletions
|
|
@ -762,6 +762,16 @@ class Actions
|
|||
$aResult['ContactsPdoPassword'] = (string)APP_DUMMY;
|
||||
|
||||
$aResult['WeakPassword'] = \is_file(APP_PRIVATE_DATA.'admin_password.txt');
|
||||
} else {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
$aResult['LanguageAdmin'] = $this->ValidateLanguage($oConfig->Get('webmail', 'language_admin', 'en'), '', true);
|
||||
|
|
|
|||
|
|
@ -661,21 +661,6 @@ 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);
|
||||
|
|
|
|||
|
|
@ -177,11 +177,6 @@ abstract class AbstractConfig implements \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
public function IsFileExists() : bool
|
||||
{
|
||||
return \file_exists($this->sFile);
|
||||
}
|
||||
|
||||
public function Load() : bool
|
||||
{
|
||||
if (\file_exists($this->sFile) && \is_readable($this->sFile))
|
||||
|
|
@ -233,7 +228,7 @@ abstract class AbstractConfig implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->Save();
|
||||
}
|
||||
|
||||
public function Save() : bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue