diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 378d33c8..803569b4 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -187,13 +187,14 @@ class SettingsController extends Controller ]; break; case 'emails': + $mail_password = Option::get('mail_password', \Config::get('mail.password')); $settings = [ 'mail_from' => \App\Misc\Mail::getSystemMailFrom(), 'mail_driver' => Option::get('mail_driver', \Config::get('mail.driver')), 'mail_host' => Option::get('mail_host', \Config::get('mail.host')), 'mail_port' => Option::get('mail_port', \Config::get('mail.port')), 'mail_username' => Option::get('mail_username', \Config::get('mail.username')), - 'mail_password' => Option::get('mail_password', \Config::get('mail.password')), + 'mail_password' => !is_null($mail_password) ? decrypt($mail_password) : null, 'mail_encryption' => Option::get('mail_encryption', \Config::get('mail.encryption')), 'fetch_schedule' => config('app.fetch_schedule'), ]; @@ -298,6 +299,7 @@ class SettingsController extends Controller // By some reason isset() does not work for empty elements. if (array_key_exists($option_name, $request->settings)) { $option_value = $request->settings[$option_name]; + if ($option_name == "mail_password") $option_value = encrypt($option_value); Option::set($option_name, $option_value); } else { // If option does not exist, default will be used, diff --git a/app/Misc/Mail.php b/app/Misc/Mail.php index f425500f..ed9cc715 100644 --- a/app/Misc/Mail.php +++ b/app/Misc/Mail.php @@ -159,7 +159,7 @@ class Mail \Config::set('mail.password', null); } else { \Config::set('mail.username', Option::get('mail_username')); - \Config::set('mail.password', Option::get('mail_password')); + \Config::set('mail.password', decrypt(Option::get('mail_password'))); } \Config::set('mail.encryption', Option::get('mail_encryption')); } diff --git a/database/migrations/2021_05_21_105200_encrypt_mail_password.php b/database/migrations/2021_05_21_105200_encrypt_mail_password.php new file mode 100644 index 00000000..2cb2d998 --- /dev/null +++ b/database/migrations/2021_05_21_105200_encrypt_mail_password.php @@ -0,0 +1,41 @@ + !is_null($mail_password) ? encrypt($mail_password) : null; + ]; + $Option->processSave($section, $settings); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + \App\Option::get('mail_password', \Config::get('mail.password')); + $section = 'emails'; + $settings = [ + 'mail_password' => !is_null($mail_password) ? decrypt($mail_password) : null; + ]; + $Option->processSave($section, $settings); + + } +} \ No newline at end of file