mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-03 10:58:50 +03:00
Make better use of SnappyMail\SensitiveString
This commit is contained in:
parent
0f7505baba
commit
7cacc9b503
18 changed files with 84 additions and 147 deletions
|
|
@ -120,25 +120,14 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
parent::Set($sSectionKey, $sParamKey, $mParamValue);
|
||||
}
|
||||
|
||||
public function SetPassword(
|
||||
#[\SensitiveParameter]
|
||||
string $sPassword
|
||||
) : void
|
||||
public function SetPassword(\SnappyMail\SensitiveString $oPassword) : void
|
||||
{
|
||||
$this->Set('security', 'admin_password', \password_hash($sPassword, PASSWORD_DEFAULT));
|
||||
$this->Set('security', 'admin_password', \password_hash($oPassword, PASSWORD_DEFAULT));
|
||||
}
|
||||
|
||||
public function ValidatePassword(
|
||||
#[\SensitiveParameter]
|
||||
string $sPassword
|
||||
) : bool
|
||||
public function ValidatePassword(\SnappyMail\SensitiveString $oPassword) : bool
|
||||
{
|
||||
$sConfigPassword = (string) $this->Get('security', 'admin_password', '');
|
||||
if (32 == \strlen($sPassword) && \md5(APP_SALT.$sPassword.APP_SALT) === $sConfigPassword) {
|
||||
$this->SetPassword($sPassword);
|
||||
return true;
|
||||
}
|
||||
return \strlen($sPassword) && \password_verify($sPassword, $sConfigPassword);
|
||||
return \strlen($oPassword) && \password_verify($oPassword, $this->Get('security', 'admin_password', ''));
|
||||
}
|
||||
|
||||
public function Save() : bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue