This commit addresses the scenario where encryption fails when the value to be encrypted is either FALSE or blank. I'm testing for !empty before doing encryption/decryption on the value and that seems to be working with this commit.

This commit is contained in:
Steve Ireland
2023-03-01 19:49:52 -05:00
parent 32ba4a9545
commit 706adf44cd
5 changed files with 51 additions and 8 deletions

View File

@@ -283,8 +283,25 @@ class Config extends Secure_Controller
{
$encrypter = Services::encrypter();
$data['mailchimp']['api_key'] = $encrypter->decrypt($this->config['mailchimp_api_key'] ?? '');
$data['mailchimp']['list_id'] = $encrypter->decrypt($this->config['mailchimp_list_id'] ?? '');
$mailchimp_api_key = $this->config['mailchimp_api_key'];
if(!empty($mailchimp_api_key))
{
$data['mailchimp']['api_key'] = $encrypter->decrypt($mailchimp_api_key);
}
else
{
$data['mailchimp']['api_key'] = '';
}
$mailchimp_list_id = $this->config['mailchimp_list_id'];
if(!empty($mailchimp_list_id))
{
$data['mailchimp']['list_id'] = $encrypter->decrypt($mailchimp_list_id);
}
else
{
$data['mailchimp']['list_id'] = '';
}
}
else
{

View File

@@ -42,7 +42,16 @@ class Customers extends Persons
$encrypter = Services::encrypter();
$this->_list_id = $encrypter->decrypt($this->config['mailchimp_list_id']);
$mailchimp_list_id = $this->config['mailchimp_list_id'];
if(!empty($mailchimp_list_id))
{
$this->_list_id = $encrypter->decrypt($this->config['mailchimp_list_id']);
}
else
{
$this->_list_id = "";
}
}
public function getIndex(): void

View File

@@ -25,8 +25,14 @@ class Email_lib
{
$this->email = new Email();
$this->config = config('OSPOS')->settings;
$encrypter = Services::encrypter();
$smtp_pass = $this->config['smtp_pass'];
if(!empty($smtp_pass))
{
$smtp_pass = $encrypter->decrypt($smtp_pass);
}
$email_config = [
'mailtype' => 'html',
@@ -36,7 +42,7 @@ class Email_lib
'mailpath' => $this->config['mailpath'],
'smtp_host' => $this->config['smtp_host'],
'smtp_user' => $this->config['smtp_user'],
'smtp_pass' => $encrypter->decrypt($this->config['smtp_pass']),
'smtp_pass' => $smtp_pass,
'smtp_port' => $this->config['smtp_port'],
'smtp_timeout' => $this->config['smtp_timeout'],
'smtp_crypto' => $this->config['smtp_crypto']

View File

@@ -41,9 +41,14 @@ class MailchimpConnector
$encrypter = Services::encrypter();
$this->_api_key = empty($api_key)
? $encrypter->decrypt($config['mailchimp_api_key']) //TODO: Hungarian notation
: $api_key; //TODO: Hungarian notation
$mailchimp_api_key = $config['mailchimp_api_key'];
if(!empty($mailchimp_api_key))
{
$this->_api_key = empty($api_key)
? $encrypter->decrypt($mailchimp_api_key) //TODO: Hungarian notation
: $api_key; //TODO: Hungarian notation
}
if(!empty($this->_api_key)) //TODO: Hungarian notation
{

View File

@@ -26,10 +26,16 @@ class Sms_lib
public function sendSMS(int $phone, string $message): bool
{
$config = config('OSPOS')->settings;
$encrypter = Services::encrypter();
$password = $config['msg_pwd'];
if(!empty($password))
{
$password = $encrypter->decrypt($password);
}
$username = $config['msg_uid'];
$password = $encrypter->decrypt($config['msg_pwd']);
$originator = $config['msg_src'];
$response = FALSE;