mirror of
https://github.com/freescout-helpdesk/freescout.git
synced 2024-11-24 03:12:46 +01:00
Merge pull request #1227 from davask/encrypt_mail_password
encrypt mail password
This commit is contained in:
commit
323524ac1b
@ -187,13 +187,14 @@ class SettingsController extends Controller
|
|||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 'emails':
|
case 'emails':
|
||||||
|
$mail_password = Option::get('mail_password', \Config::get('mail.password'));
|
||||||
$settings = [
|
$settings = [
|
||||||
'mail_from' => \App\Misc\Mail::getSystemMailFrom(),
|
'mail_from' => \App\Misc\Mail::getSystemMailFrom(),
|
||||||
'mail_driver' => Option::get('mail_driver', \Config::get('mail.driver')),
|
'mail_driver' => Option::get('mail_driver', \Config::get('mail.driver')),
|
||||||
'mail_host' => Option::get('mail_host', \Config::get('mail.host')),
|
'mail_host' => Option::get('mail_host', \Config::get('mail.host')),
|
||||||
'mail_port' => Option::get('mail_port', \Config::get('mail.port')),
|
'mail_port' => Option::get('mail_port', \Config::get('mail.port')),
|
||||||
'mail_username' => Option::get('mail_username', \Config::get('mail.username')),
|
'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')),
|
'mail_encryption' => Option::get('mail_encryption', \Config::get('mail.encryption')),
|
||||||
'fetch_schedule' => config('app.fetch_schedule'),
|
'fetch_schedule' => config('app.fetch_schedule'),
|
||||||
];
|
];
|
||||||
@ -298,6 +299,7 @@ class SettingsController extends Controller
|
|||||||
// By some reason isset() does not work for empty elements.
|
// By some reason isset() does not work for empty elements.
|
||||||
if (array_key_exists($option_name, $request->settings)) {
|
if (array_key_exists($option_name, $request->settings)) {
|
||||||
$option_value = $request->settings[$option_name];
|
$option_value = $request->settings[$option_name];
|
||||||
|
if ($option_name == "mail_password") $option_value = encrypt($option_value);
|
||||||
Option::set($option_name, $option_value);
|
Option::set($option_name, $option_value);
|
||||||
} else {
|
} else {
|
||||||
// If option does not exist, default will be used,
|
// If option does not exist, default will be used,
|
||||||
|
@ -159,7 +159,7 @@ class Mail
|
|||||||
\Config::set('mail.password', null);
|
\Config::set('mail.password', null);
|
||||||
} else {
|
} else {
|
||||||
\Config::set('mail.username', Option::get('mail_username'));
|
\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'));
|
\Config::set('mail.encryption', Option::get('mail_encryption'));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class EncryptOptionPassword extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
\App\Option::get('mail_password', \Config::get('mail.password'));
|
||||||
|
$section = 'emails';
|
||||||
|
$settings = [
|
||||||
|
'mail_password' => !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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user