Improved install process

1. If Attendize is already installed don't throw an Unauthorized 403 error but instead ask user to create default account or login if default account already created.
2. Added defaults to the install process for database connection so if user gets to install page and hits install will use default database values.
3. Added basic validation on database connection details. If the details where empty previously allowed user to submit form.
This commit is contained in:
Jeremy Quinton 2018-07-04 16:54:33 +02:00
parent 915f1f8722
commit fe65e36c57
4 changed files with 119 additions and 56 deletions

View File

@ -14,16 +14,7 @@ class InstallerController extends Controller
/**
* InstallerController constructor.
*/
public function __construct()
{
/**
* If we're already installed kill the request
* @todo Check if DB is installed etc.
*/
if (file_exists(base_path('installed'))) {
abort(403, 'Unauthorized action.');
}
}
public function __construct(){}
/**
* Show the application installer
@ -68,6 +59,18 @@ class InstallerController extends Controller
'pdo_pgsql',
];
/**
* If we're already installed display user friendly message and direct them to the appropriate next steps.
*
* @todo Check if DB is installed etc.
* @todo Add some automated checks to see exactly what the state of the install is. Potentially would be nice to
* allow the user to restart the install process
*/
if (file_exists(base_path('installed'))) {
return view('Installer.AlreadyInstalled', $data);
}
return view('Installer.Installer', $data);
}
@ -87,6 +90,14 @@ class InstallerController extends Controller
$database['username'] = $request->get('database_username');
$database['password'] = $request->get('database_password');
$this->validate($request, [
'database_type' => 'required',
'database_host' => 'required',
'database_name' => 'required',
'database_username' => 'required',
'database_password' => 'required']);
$mail['driver'] = $request->get('mail_driver');
$mail['port'] = $request->get('mail_port');
$mail['username'] = $request->get('mail_username');

View File

@ -1,46 +1,50 @@
<?php
/*************************************************************************
Generated via "php artisan localization:missing" at 2018/04/17 16:35:44
*************************************************************************/
* Generated via "php artisan localization:missing" at 2018/04/17 16:35:44
*************************************************************************/
return array (
return array(
'connection_success' => 'Success, Your connection works!',
'connection_failure' => 'Unable to connect! Please check your settings',
'app_settings' => 'App settings',
'application_url' => 'Application URL',
'database_host' => 'Database Host',
'database_name' => 'Database Name',
'database_password' => 'Database Password',
'database_settings' => 'Database Settings',
'database_test_connect_failure' => 'Unable to connect. Please check your settings.',
'database_test_connect_failure_error_message' => 'Error Message',
'database_test_connect_failure_error_type' => 'Error Type',
'database_test_connect_failure_message' => 'Unable to connect. Please check your settings.',
'database_test_connect_success' => 'Success! Database settings are working!',
'database_type' => 'Database Type',
'database_username' => 'Database Username',
'email_settings' => 'Email Settings',
'files_n_folders_check' => 'Files & Folders Check',
'install' => 'Install Attendize',
'mail_encryption' => 'Mail Encryption',
'mail_from_address' => 'Mail From Address',
'mail_from_help' => 'To use PHP\'s <a target="_blank" href="http://php.net/manual/en/function.mail.php">mail</a> feature enter <b>mail</b> in this box and leave the below fields empty.',
'mail_from_name' => 'Mail From Name',
'mail_host' => 'Mail Host',
'mail_password' => 'Mail Password',
'mail_port' => 'Mail Port',
'mail_username' => 'Mail Username',
'optional_requirement_not_met' => 'Warning: <b>:requirement</b> extension is not loaded',
'path_not_writable' => 'Warning: <b>:path</b> is not writable',
'path_writable' => 'Success: <b>:path</b> is writable',
'php_enough' => 'Success: The application requires PHP >= <b>:requires</b> and yours is <b>:has</b>',
'php_optional_requirements_check' => 'PHP Optional Requirements Check',
'php_requirements_check' => 'PHP Requirements Check',
'php_too_low' => 'Warning: The application requires PHP >= <b>:requires.</b> Your version is <b>:has</b>.',
'php_version_check' => 'PHP Version Check',
'requirement_met' => 'Success: <b>:requirement</b> extension is loaded',
'requirement_not_met' => 'Error: <b>:requirement</b> extension is not loaded',
'setup' => 'Attendize Setup',
'test_database_connection' => 'Test Database Connection',
'title' => 'Attendize Web Installer',
);
'app_settings' => 'App settings',
'application_url' => 'Application URL',
'database_host' => 'Database Host',
'database_name' => 'Database Name',
'database_password' => 'Database Password',
'database_settings' => 'Database Settings',
'database_message' => 'If you are using the docker environment for development you can simple use the pre-filled values. If you are using your own environment you will need to update the database settings. Use the Test Database Connection to ensure your details are correct. In correct database details will result in installation issues.',
'database_test_connect_failure' => 'Unable to connect. Please check your settings.',
'database_test_connect_failure_error_message' => 'Error Message',
'database_test_connect_failure_error_type' => 'Error Type',
'database_test_connect_failure_message' => 'Unable to connect. Please check your settings.',
'database_test_connect_success' => 'Success! Database settings are working!',
'database_type' => 'Database Type',
'database_username' => 'Database Username',
'email_settings' => 'Email Settings',
'files_n_folders_check' => 'Files & Folders Check',
'install' => 'Install Attendize',
'mail_encryption' => 'Mail Encryption',
'mail_from_address' => 'Mail From Address',
'mail_from_help' => 'To use PHP\'s <a target="_blank" href="http://php.net/manual/en/function.mail.php">mail</a> feature enter <b>mail</b> in this box and leave the below fields empty.',
'mail_from_name' => 'Mail From Name',
'mail_host' => 'Mail Host',
'mail_password' => 'Mail Password',
'mail_port' => 'Mail Port',
'mail_username' => 'Mail Username',
'optional_requirement_not_met' => 'Warning: <b>:requirement</b> extension is not loaded',
'path_not_writable' => 'Warning: <b>:path</b> is not writable',
'path_writable' => 'Success: <b>:path</b> is writable',
'php_enough' => 'Success: The application requires PHP >= <b>:requires</b> and yours is <b>:has</b>',
'php_optional_requirements_check' => 'PHP Optional Requirements Check',
'php_requirements_check' => 'PHP Requirements Check',
'php_too_low' => 'Warning: The application requires PHP >= <b>:requires.</b> Your version is <b>:has</b>.',
'php_version_check' => 'PHP Version Check',
'requirement_met' => 'Success: <b>:requirement</b> extension is loaded',
'requirement_not_met' => 'Error: <b>:requirement</b> extension is not loaded',
'setup' => 'Attendize Setup',
'setup_completed' => 'Attendize Setup Already',
'setup_completed_already_message' => "An install file has been detected which means Attendize setup process has already completed. <br /> If you haven't setup a default user you can " .
"<a href='/signup'>Signup Default User</a><br />If you have already created a default user you can <a href='/login'>Login Here </a>",
'test_database_connection' => 'Test Database Connection',
'title' => 'Attendize Web Installer',
);

View File

@ -0,0 +1,37 @@
@extends('Shared.Layouts.MasterWithoutMenus')
@section('title')
@lang("Installer.title")
@stop
@section('head')
<style>
.modal-header {
background-color: transparent !important;
color: #666 !important;
text-shadow: none !important;;
}
.alert-success {
background-color: #dff0d8 !important;
border-color: #d6e9c6 !important;
color: #3c763d !important;
}
</style>
@stop
@section('content')
<div class="row">
<div class="col-md-7 col-md-offset-2">
<div class="panel">
<div class="panel-body">
<div class="logo">
{!!HTML::image('assets/images/logo-dark.png')!!}
</div>
<h1>@lang("Installer.setup_completed")</h1>
<p>@lang("Installer.setup_completed_already_message")</p>
</div>
</div>
</div>
</div>
@stop

View File

@ -29,7 +29,15 @@
</div>
<h1>@lang("Installer.setup")</h1>
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<h3>@lang("Installer.php_version_check")</h3>
@if (version_compare(phpversion(), '5.5.9', '<'))
@ -102,6 +110,7 @@
</div>
<h3>@lang("Installer.database_settings")</h3>
<p>@lang("Installer.database_message")</p>
<div class="form-group">
{!! Form::label('database_type', trans("Installer.database_type"), array('class'=>'required control-label ')) !!}
@ -116,16 +125,18 @@
<div class="form-group">
{!! Form::label('database_host', trans("Installer.database_host"), array('class'=>'control-label required')) !!}
{!! Form::text('database_host', Input::old('database_host'),
{!! Form::text('database_host', 'db',
array(
'class'=>'form-control ',
'placeholder'=>''
)) !!}
</div>
<div class="form-group">
{!! Form::label('database_name', trans("Installer.database_name"), array('class'=>'required control-label ')) !!}
{!! Form::text('database_name', Input::old('database_name'),
{!! Form::text('database_name', 'attendize',
array(
'class'=>'form-control'
)) !!}
@ -133,7 +144,7 @@
<div class="form-group">
{!! Form::label('database_username', trans("Installer.database_username"), array('class'=>'control-label required')) !!}
{!! Form::text('database_username', Input::old('database_username'),
{!! Form::text('database_username', 'attendize',
array(
'class'=>'form-control ',
'placeholder'=>'',
@ -141,7 +152,7 @@
</div>
<div class="form-group">
{!! Form::label('database_password', trans("Installer.database_password"), array('class'=>'control-label ')) !!}
{!! Form::text('database_password', Input::old('database_password'),
{!! Form::text('database_password', 'attendize',
array(
'class'=>'form-control ',
'placeholder'=>'',