diff --git a/app/Controllers/Config.php b/app/Controllers/Config.php index 0143b646a..2d571b0a2 100644 --- a/app/Controllers/Config.php +++ b/app/Controllers/Config.php @@ -20,6 +20,7 @@ use App\Models\Tax; use CodeIgniter\Encryption\Encryption; use CodeIgniter\Encryption\EncrypterInterface; use CodeIgniter\Files\File; +use Config\Services; use DirectoryIterator; use NumberFormatter; use ReflectionException; @@ -59,9 +60,6 @@ class Config extends Secure_Controller $this->rounding_mode = model('Rounding_mode'); $this->stock_location = model('Stock_location'); $this->tax = model('Tax'); - - $this->encryption = new Encryption(); - $this->encrypter = $this->encryption->initialize(); } /* @@ -278,8 +276,10 @@ class Config extends Secure_Controller if($this->_check_encryption()) //TODO: Hungarian notation { - $data['mailchimp']['api_key'] = $this->encrypter->decrypt(config('OSPOS')->settings['mailchimp_api_key']); - $data['mailchimp']['list_id'] = $this->encrypter->decrypt(config('OSPOS')->settings['mailchimp_list_id']); + $encrypter = Services::encrypter(); + + $data['mailchimp']['api_key'] = $encrypter->decrypt(config('OSPOS')->settings['mailchimp_api_key']); + $data['mailchimp']['list_id'] = $encrypter->decrypt(config('OSPOS')->settings['mailchimp_list_id']); } else { @@ -984,4 +984,4 @@ class Config extends Secure_Controller return TRUE; } -} \ No newline at end of file +} diff --git a/app/Controllers/Customers.php b/app/Controllers/Customers.php index b8377fc44..8262abe46 100644 --- a/app/Controllers/Customers.php +++ b/app/Controllers/Customers.php @@ -10,6 +10,7 @@ use App\Models\Tax_code; use CodeIgniter\Encryption\Encryption; use CodeIgniter\Encryption\EncrypterInterface; +use Config\Services; use stdClass; /** @@ -38,10 +39,9 @@ class Customers extends Persons $this->customer = model('Customer'); $this->tax_code = model('Tax_code'); - $this->encryption = new Encryption(); - $this->encrypter = $this->encryption->initialize(); + $encrypter = Services::encrypter(); - $this->_list_id = $this->encrypter->decrypt(config('OSPOS')->settings['mailchimp_list_id']); + $this->_list_id = $encrypter->decrypt(config('OSPOS')->settings['mailchimp_list_id']); } public function getIndex(): void @@ -500,4 +500,4 @@ class Customers extends Persons } } } -} \ No newline at end of file +} diff --git a/app/Libraries/Email_lib.php b/app/Libraries/Email_lib.php index 7ea932aee..73f6bcc6a 100644 --- a/app/Libraries/Email_lib.php +++ b/app/Libraries/Email_lib.php @@ -5,6 +5,7 @@ namespace app\Libraries; use CodeIgniter\Email\Email; use CodeIgniter\Encryption\Encryption; use CodeIgniter\Encryption\EncrypterInterface; +use Config\Services; /** @@ -22,9 +23,7 @@ class Email_lib public function __construct() { $this->email = new Email(); - $this->encryption = new Encryption(); - $this->encrypter = $this->encryption->initialize(); - + $encrypter = Services::encrypter(); $config = [ 'mailtype' => 'html', @@ -34,7 +33,7 @@ class Email_lib 'mailpath' => config('OSPOS')->settings['mailpath'], 'smtp_host' => config('OSPOS')->settings['smtp_host'], 'smtp_user' => config('OSPOS')->settings['smtp_user'], - 'smtp_pass' => $this->encrypter->decrypt(config('OSPOS')->settings['smtp_pass']), + 'smtp_pass' => $encrypter->decrypt(config('OSPOS')->settings['smtp_pass']), 'smtp_port' => config('OSPOS')->settings['smtp_port'], 'smtp_timeout' => config('OSPOS')->settings['smtp_timeout'], 'smtp_crypto' => config('OSPOS')->settings['smtp_crypto'] @@ -70,4 +69,4 @@ class Email_lib return $result; } -} \ No newline at end of file +} diff --git a/app/Libraries/Sms_lib.php b/app/Libraries/Sms_lib.php index 7d85280f9..082a38079 100644 --- a/app/Libraries/Sms_lib.php +++ b/app/Libraries/Sms_lib.php @@ -4,6 +4,7 @@ namespace app\Libraries; use CodeIgniter\Encryption\Encryption; use CodeIgniter\Encryption\EncrypterInterface; +use Config\Services; /** @@ -20,8 +21,6 @@ class Sms_lib { public function __construct() { - $this->encryption = new Encryption(); //TODO: Is this the correct way to load the encryption service now? - $this->encrypter = $this->encryption->initialize(); } /* @@ -30,8 +29,10 @@ class Sms_lib */ public function sendSMS(int $phone, string $message): bool { + $encrypter = Services::encrypter(); + $username = config('OSPOS')->settings['msg_uid']; - $password = $this->encrypter->decrypt(config('OSPOS')->settings['msg_pwd']); + $password = $encrypter->decrypt(config('OSPOS')->settings['msg_pwd']); $originator = config('OSPOS')->settings['msg_src']; $response = FALSE; @@ -78,4 +79,4 @@ class Sms_lib return $response; } -} \ No newline at end of file +}