Fix some error conditions in installer; hide passwords in logs

This commit is contained in:
Nabeel Shahzad 2018-02-25 15:27:20 -06:00
parent d9abaa2f06
commit 4393523929
4 changed files with 21 additions and 10 deletions

View File

@ -159,13 +159,17 @@ class InstallerController extends Controller
public function envsetup(Request $request) public function envsetup(Request $request)
{ {
$log_str = $request->post(); $log_str = $request->post();
$log_str['password'] = ''; $log_str['db_pass'] = '';
Log::info('ENV setup', $log_str); Log::info('ENV setup', $log_str);
// Before writing out the env file, test the DB credentials // Before writing out the env file, test the DB credentials
try { try {
$this->testDb($request); $this->testDb($request);
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('Testing db before writing configs failed');
Log::error($e->getMessage());
flash()->error($e->getMessage()); flash()->error($e->getMessage());
return redirect(route('installer.step2'))->withInput(); return redirect(route('installer.step2'))->withInput();
} }
@ -191,6 +195,9 @@ class InstallerController extends Controller
try { try {
$this->envService->createConfigFiles($attrs); $this->envService->createConfigFiles($attrs);
} catch(FileException $e) { } catch(FileException $e) {
Log::error('Config files failed to write');
Log::error($e->getMessage());
flash()->error($e->getMessage()); flash()->error($e->getMessage());
return redirect(route('installer.step2'))->withInput(); return redirect(route('installer.step2'))->withInput();
} }
@ -213,6 +220,8 @@ class InstallerController extends Controller
$console_out .= $this->dbService->setupDB(); $console_out .= $this->dbService->setupDB();
$console_out .= $this->migrationSvc->runAllMigrations(); $console_out .= $this->migrationSvc->runAllMigrations();
} catch(QueryException $e) { } catch(QueryException $e) {
Log::error('Error on db setup: ' . $e->getMessage());
$this->envService->removeConfigFiles(); $this->envService->removeConfigFiles();
flash()->error($e->getMessage()); flash()->error($e->getMessage());
return redirect(route('installer.step2'))->withInput(); return redirect(route('installer.step2'))->withInput();

View File

@ -45,10 +45,7 @@
<td>Database Host</td> <td>Database Host</td>
<td style="text-align:center;"> <td style="text-align:center;">
<div class="form-group"> <div class="form-group">
{!! Form::text('db_host', null, [ {!! Form::input('text', 'db_host', '127.0.0.1', ['class' => 'form-control']) !!}
'class' => 'form-control',
'placeholder' => 'localhost',
]) !!}
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -2,10 +2,10 @@
namespace Modules\Installer\Services; namespace Modules\Installer\Services;
use Log;
use PDO;
use Nwidart\Modules\Support\Stub;
use Illuminate\Encryption\Encrypter; use Illuminate\Encryption\Encrypter;
use Log;
use Nwidart\Modules\Support\Stub;
use PDO;
use Symfony\Component\HttpFoundation\File\Exception\FileException; use Symfony\Component\HttpFoundation\File\Exception\FileException;
/** /**

View File

@ -9,12 +9,17 @@ class DatabaseService {
/** /**
* Check the PHP version that it meets the minimum requirement * Check the PHP version that it meets the minimum requirement
* @throws \PDOException * @param $driver
* @param $host
* @param $port
* @param $name
* @param $user
* @param $pass
* @return boolean * @return boolean
*/ */
public function checkDbConnection($driver, $host, $port, $name, $user, $pass) public function checkDbConnection($driver, $host, $port, $name, $user, $pass)
{ {
Log::info('Testing Connection: '.$driver.'::'.$user.':'.$pass.'@'.$host.':'.$port.';'.$name); Log::info('Testing Connection: '.$driver.'::'.$user.':<hidden>@'.$host.':'.$port.';'.$name);
if($driver === 'mysql') { if($driver === 'mysql') {
$dsn = "mysql:host=$host;port=$port;dbname=$name"; $dsn = "mysql:host=$host;port=$port;dbname=$name";