fix
This commit is contained in:
@@ -39,6 +39,19 @@ class EmailSettings extends Component
|
|||||||
'model.smtp.password' => 'Password',
|
'model.smtp.password' => 'Password',
|
||||||
'model.smtp.test_recipients' => 'Test Recipients',
|
'model.smtp.test_recipients' => 'Test Recipients',
|
||||||
];
|
];
|
||||||
|
private function decrypt()
|
||||||
|
{
|
||||||
|
if (data_get($this->model, 'smtp.password')) {
|
||||||
|
try {
|
||||||
|
$this->model->smtp->password = decrypt($this->model->smtp->password);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->decrypt();
|
||||||
|
}
|
||||||
public function copyFromInstanceSettings()
|
public function copyFromInstanceSettings()
|
||||||
{
|
{
|
||||||
$settings = InstanceSettings::get();
|
$settings = InstanceSettings::get();
|
||||||
@@ -63,6 +76,13 @@ class EmailSettings extends Component
|
|||||||
{
|
{
|
||||||
$this->resetErrorBag();
|
$this->resetErrorBag();
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
|
||||||
|
if ($this->model->smtp->password) {
|
||||||
|
$this->model->smtp->password = encrypt($this->model->smtp->password);
|
||||||
|
} else {
|
||||||
|
$this->model->smtp->password = null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->model->smtp->recipients = str_replace(' ', '', $this->model->smtp->recipients);
|
$this->model->smtp->recipients = str_replace(' ', '', $this->model->smtp->recipients);
|
||||||
$this->model->smtp->test_recipients = str_replace(' ', '', $this->model->smtp->test_recipients);
|
$this->model->smtp->test_recipients = str_replace(' ', '', $this->model->smtp->test_recipients);
|
||||||
$this->saveModel();
|
$this->saveModel();
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ class Email extends Component
|
|||||||
'settings.smtp.password' => 'Password',
|
'settings.smtp.password' => 'Password',
|
||||||
'settings.smtp.test_recipients' => 'Test Recipients',
|
'settings.smtp.test_recipients' => 'Test Recipients',
|
||||||
];
|
];
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
$this->decrypt();
|
||||||
|
}
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -48,10 +52,27 @@ class Email extends Component
|
|||||||
Notification::send($this->settings, new TestEmail);
|
Notification::send($this->settings, new TestEmail);
|
||||||
$this->emit('success', 'Test email sent.');
|
$this->emit('success', 'Test email sent.');
|
||||||
}
|
}
|
||||||
|
private function decrypt()
|
||||||
|
{
|
||||||
|
if (data_get($this->settings, 'smtp.password')) {
|
||||||
|
try {
|
||||||
|
$this->settings->smtp->password = decrypt($this->settings->smtp->password);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
|
$this->resetErrorBag();
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
if ($this->settings->smtp->password) {
|
||||||
|
$this->settings->smtp->password = encrypt($this->settings->smtp->password);
|
||||||
|
} else {
|
||||||
|
$this->settings->smtp->password = null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->settings->smtp->test_recipients = str_replace(' ', '', $this->settings->smtp->test_recipients);
|
$this->settings->smtp->test_recipients = str_replace(' ', '', $this->settings->smtp->test_recipients);
|
||||||
$this->settings->save();
|
$this->settings->save();
|
||||||
|
$this->decrypt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class EmailChannel
|
|||||||
|
|
||||||
private function bootConfigs($notifiable): void
|
private function bootConfigs($notifiable): void
|
||||||
{
|
{
|
||||||
|
$password = data_get($notifiable, 'smtp.password');
|
||||||
|
if ($password) $password = decrypt($password);
|
||||||
|
|
||||||
config()->set('mail.default', 'smtp');
|
config()->set('mail.default', 'smtp');
|
||||||
config()->set('mail.mailers.smtp', [
|
config()->set('mail.mailers.smtp', [
|
||||||
"transport" => "smtp",
|
"transport" => "smtp",
|
||||||
@@ -42,7 +45,7 @@ class EmailChannel
|
|||||||
"port" => data_get($notifiable, 'smtp.port'),
|
"port" => data_get($notifiable, 'smtp.port'),
|
||||||
"encryption" => data_get($notifiable, 'smtp.encryption'),
|
"encryption" => data_get($notifiable, 'smtp.encryption'),
|
||||||
"username" => data_get($notifiable, 'smtp.username'),
|
"username" => data_get($notifiable, 'smtp.username'),
|
||||||
"password" => data_get($notifiable, 'smtp.password'),
|
"password" => $password,
|
||||||
"timeout" => data_get($notifiable, 'smtp.timeout'),
|
"timeout" => data_get($notifiable, 'smtp.timeout'),
|
||||||
"local_domain" => null,
|
"local_domain" => null,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ function is_transactional_emails_active()
|
|||||||
function set_transanctional_email_settings()
|
function set_transanctional_email_settings()
|
||||||
{
|
{
|
||||||
$settings = InstanceSettings::get();
|
$settings = InstanceSettings::get();
|
||||||
|
$password = data_get($settings, 'smtp.password');
|
||||||
|
if ($password) $password = decrypt($password);
|
||||||
|
|
||||||
config()->set('mail.default', 'smtp');
|
config()->set('mail.default', 'smtp');
|
||||||
config()->set('mail.mailers.smtp', [
|
config()->set('mail.mailers.smtp', [
|
||||||
"transport" => "smtp",
|
"transport" => "smtp",
|
||||||
@@ -82,7 +85,7 @@ function set_transanctional_email_settings()
|
|||||||
"port" => data_get($settings, 'smtp.port'),
|
"port" => data_get($settings, 'smtp.port'),
|
||||||
"encryption" => data_get($settings, 'smtp.encryption'),
|
"encryption" => data_get($settings, 'smtp.encryption'),
|
||||||
"username" => data_get($settings, 'smtp.username'),
|
"username" => data_get($settings, 'smtp.username'),
|
||||||
"password" => data_get($settings, 'smtp.password'),
|
"password" => $password,
|
||||||
"timeout" => data_get($settings, 'smtp.timeout'),
|
"timeout" => data_get($settings, 'smtp.timeout'),
|
||||||
"local_domain" => null,
|
"local_domain" => null,
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user