forked from ZwiiCMS-Team/ZwiiCMS
Mail auth WIP
This commit is contained in:
parent
ca87ee2d3b
commit
53b78bf61d
@ -682,28 +682,4 @@ class helper
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Cryptage
|
|
||||||
* @param string $key la clé d'encryptage
|
|
||||||
* @param string $payload la chaine à coder
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function encrypt($key, $payload)
|
|
||||||
{
|
|
||||||
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
|
|
||||||
$encrypted = openssl_encrypt($payload, 'aes-256-cbc', $key, 0, $iv);
|
|
||||||
return base64_encode($encrypted . '::' . $iv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Décryptage
|
|
||||||
* @param string $key la clé d'encryptage
|
|
||||||
* @param string $garble la chaine à décoder
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function decrypt($key, $garble)
|
|
||||||
{
|
|
||||||
list($encrypted_data, $iv) = explode('::', base64_decode($garble), 2);
|
|
||||||
return openssl_decrypt($encrypted_data, 'aes-256-cbc', $key, 0, $iv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1146,12 +1146,10 @@ class common
|
|||||||
$mail->Host = $this->getdata(['config', 'smtp', 'host']);
|
$mail->Host = $this->getdata(['config', 'smtp', 'host']);
|
||||||
$mail->Port = (int) $this->getdata(['config', 'smtp', 'port']);
|
$mail->Port = (int) $this->getdata(['config', 'smtp', 'port']);
|
||||||
if ($this->getData(['config', 'smtp', 'auth'])) {
|
if ($this->getData(['config', 'smtp', 'auth'])) {
|
||||||
$mail->SMTPAutoTLS = true;
|
|
||||||
$mail->SMTPSecure = true;
|
$mail->SMTPSecure = true;
|
||||||
$mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']);
|
$mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']);
|
||||||
$mail->Username = $this->getData(['config', 'smtp', 'username']);
|
$mail->Username = $this->getData(['config', 'smtp', 'username']);
|
||||||
$mail->Password = helper::decrypt($this->getData(['config', 'smtp', 'username']), $this->getData(['config', 'smtp', 'password']));
|
$mail->Password = $this->getData(['config', 'smtp', 'password']);
|
||||||
$mail->SMTPSecure = $this->getData(['config', 'smtp', 'secure']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,12 +455,12 @@ class config extends common
|
|||||||
],
|
],
|
||||||
'smtp' => [
|
'smtp' => [
|
||||||
'enable' => $this->getInput('smtpEnable', helper::FILTER_BOOLEAN),
|
'enable' => $this->getInput('smtpEnable', helper::FILTER_BOOLEAN),
|
||||||
'host' => $this->getInput('smtpHost', helper::FILTER_STRING_SHORT, $this->getInput('smtpEnable', helper::FILTER_BOOLEAN)),
|
'host' => $this->getInput('smtpHost', helper::FILTER_STRING_SHORT),
|
||||||
'port' => $this->getInput('smtpPort', helper::FILTER_INT, $this->getInput('smtpEnable', helper::FILTER_BOOLEAN)),
|
'port' => $this->getInput('smtpPort', helper::FILTER_INT),
|
||||||
'auth' => $this->getInput('smtpAuth', helper::FILTER_BOOLEAN),
|
'auth' => $this->getInput('smtpAuth', helper::FILTER_BOOLEAN),
|
||||||
'secure' => $this->getInput('smtpSecure', helper::FILTER_STRING_SHORT),
|
'secure' => $this->getInput('smtpSecure', helper::FILTER_STRING_SHORT),
|
||||||
'username' => $this->getInput('smtpUsername', helper::FILTER_STRING_SHORT, $this->getInput('smtpAuth', helper::FILTER_BOOLEAN)),
|
'username' => $this->getInput('smtpUsername', helper::FILTER_STRING_SHORT),
|
||||||
'password' => helper::encrypt($this->getData(['config', 'smtp', 'username']), $this->getInput('smtpPassword', null, $this->getInput('smtpAuth', helper::FILTER_BOOLEAN))),
|
'password' => $this->getInput('smtpPassword', helper::FILTER_STRING_SHORT),
|
||||||
'from' => $this->getInput('smtpFrom', helper::FILTER_MAIL, true),
|
'from' => $this->getInput('smtpFrom', helper::FILTER_MAIL, true),
|
||||||
],
|
],
|
||||||
'seo' => [
|
'seo' => [
|
||||||
|
@ -491,7 +491,7 @@ class form extends common
|
|||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'notification' => ($sent === true ? helper::translate('Formulaire soumis') : $sent),
|
'notification' => ($sent === true ? helper::translate('Formulaire soumis') : $sent),
|
||||||
'redirect' => $redirect ? helper::baseUrl() . $redirect : '',
|
'redirect' => $redirect ? helper::baseUrl() . $redirect : '',
|
||||||
'state' => ($sent === true ? true : null),
|
'state' => ($sent === true ? true : false),
|
||||||
'vendor' => [
|
'vendor' => [
|
||||||
'flatpickr'
|
'flatpickr'
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user