From 2c53f091b9d2cd2d09aaf407b39436a6ee437000 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 31 Dec 2017 12:09:23 -0600 Subject: [PATCH] installer fixes; user's name --- Makefile | 6 ++--- Procfile | 2 +- app/Console/Commands/DevCommands.php | 26 ++++++++++++++++++- .../Http/Controllers/InstallerController.php | 5 ++-- .../views/steps/step3-user.blade.php | 12 ++++++++- .../Resources/views/stubs/env.blade.php | 6 ++--- 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 6e1ac5d9..8083fafe 100644 --- a/Makefile +++ b/Makefile @@ -90,10 +90,8 @@ deploy-package: .PHONY: reset-installer reset-installer: - @cp .env.dev.example .env - @make clean - mysql -uroot -e "DROP DATABASE IF EXISTS phpvms" - mysql -uroot -e "CREATE DATABASE phpvms" + @php artisan database:create --reset + @php artisan migrate:refresh --seed .PHONY: docker docker: diff --git a/Procfile b/Procfile index dd368790..1729d537 100644 --- a/Procfile +++ b/Procfile @@ -1,5 +1,5 @@ dnsmasq: /usr/local/sbin/dnsmasq --keep-in-foreground php-fpm: /usr/local/sbin/php-fpm --nodaemonize nginx: /usr/local/bin/nginx -#mysql: /usr/local/bin/mysqld +mysql: /usr/local/bin/mysqld mailhog: /usr/local/bin/mailhog diff --git a/app/Console/Commands/DevCommands.php b/app/Console/Commands/DevCommands.php index 308f7348..3146934f 100644 --- a/app/Console/Commands/DevCommands.php +++ b/app/Console/Commands/DevCommands.php @@ -2,6 +2,10 @@ namespace App\Console\Commands; +use App\Models\Airline; +use App\Models\Permission; +use App\Models\Role; +use App\Models\User; use App\Services\DatabaseService; use DB; @@ -28,8 +32,8 @@ class DevCommands extends BaseCommand $commands = [ 'clear-acars' => 'clearAcars', + 'clear-users' => 'clearUsers', 'compile-assets' => 'compileAssets', - 'test-api' => 'testApi', ]; if(!array_key_exists($command, $commands)) { @@ -59,6 +63,26 @@ class DevCommands extends BaseCommand $this->info('ACARS and PIREPs cleared!'); } + /** + * Delete all the data from the ACARS and PIREP tables + */ + protected function clearUsers() + { + if (config('database.default') === 'mysql') { + DB::statement('SET foreign_key_checks=0'); + } + + DB::statement('TRUNCATE `role_user`'); + Airline::truncate(); + User::truncate(); + + if (config('database.default') === 'mysql') { + DB::statement('SET foreign_key_checks=1'); + } + + $this->info('Users cleared!'); + } + /** * Compile all the CSS/JS assets into their respective files * Calling the webpack compiler diff --git a/modules/Installer/Http/Controllers/InstallerController.php b/modules/Installer/Http/Controllers/InstallerController.php index 4390f858..e0e203bb 100644 --- a/modules/Installer/Http/Controllers/InstallerController.php +++ b/modules/Installer/Http/Controllers/InstallerController.php @@ -217,6 +217,7 @@ class InstallerController extends AppBaseController $validator = Validator::make($request->all(), [ 'airline_name' => 'required', 'airline_icao' => 'required|unique:airlines,icao', + 'name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required|confirmed' ]); @@ -259,9 +260,7 @@ class InstallerController extends AppBaseController Log::info('User registered: ', $user->toArray()); # Set the intial admin e-mail address - $admin_email = Setting::where('key', 'general.admin_email'); - $admin_email->value = $user->email; - $admin_email->save(); + setting('general.admin_email', $user->email); return view('installer::steps/step3a-completed', []); } diff --git a/modules/Installer/Resources/views/steps/step3-user.blade.php b/modules/Installer/Resources/views/steps/step3-user.blade.php index 15607860..ac58d31c 100644 --- a/modules/Installer/Resources/views/steps/step3-user.blade.php +++ b/modules/Installer/Resources/views/steps/step3-user.blade.php @@ -36,7 +36,17 @@ -

Admin Email

+

Name

+ +
+ {!! Form::input('text', 'name', null, ['class' => 'form-control']) !!} + @include('installer::flash/check_error', ['field' => 'name']) +
+ + + + +

Email

{!! Form::input('text', 'email', null, ['class' => 'form-control']) !!} diff --git a/modules/Installer/Resources/views/stubs/env.blade.php b/modules/Installer/Resources/views/stubs/env.blade.php index 111c8405..ca093249 100644 --- a/modules/Installer/Resources/views/stubs/env.blade.php +++ b/modules/Installer/Resources/views/stubs/env.blade.php @@ -30,9 +30,9 @@ DB_PREFIX= MAIL_DRIVER=smtp MAIL_FROM_ADDRESS=no-reply@phpvms.net MAIL_FROM_NAME="phpVMS Admin" -MAIL_HOST=smtp.mailgun.org -MAIL_PORT=587 -MAIL_ENCRYPTION=tls +MAIL_HOST= +MAIL_PORT= +MAIL_ENCRYPTION= MAIL_USERNAME= MAIL_PASSWORD=