From 9b629ae7003a4fafa285ba26191c92e256b92ca3 Mon Sep 17 00:00:00 2001 From: Erik Campobadal Date: Wed, 31 Aug 2016 05:44:59 +0200 Subject: [PATCH] Fixed database error before installation --- .../Laralum/InstallerController.php | 9 ++++- app/Http/Controllers/Laralum/Laralum.php | 7 ++-- app/Http/Middleware/Laralum/Authenticate.php | 13 +++--- app/Http/Middleware/Laralum/Base.php | 40 ++++++++++--------- readme.md | 30 +++++++++++--- routes/web.php | 5 --- 6 files changed, 62 insertions(+), 42 deletions(-) diff --git a/app/Http/Controllers/Laralum/InstallerController.php b/app/Http/Controllers/Laralum/InstallerController.php index b9b71d1..1828356 100644 --- a/app/Http/Controllers/Laralum/InstallerController.php +++ b/app/Http/Controllers/Laralum/InstallerController.php @@ -44,7 +44,7 @@ public function installConfig($locale, Request $request) $this->validate($request, [ 'USER_NAME' => 'required', - 'USER_PASSWORD' => 'required|confirmed', + 'USER_PASSWORD' => 'required|min:6|confirmed', 'USER_EMAIL' => 'required', 'USER_COUNTRY_CODE' => 'required', 'USER_LOCALE' => 'required', @@ -76,11 +76,16 @@ public function installConfig($locale, Request $request) public function install($locale) { if(!Laralum::checkInstalled()){ - + $exitCode = Artisan::call('migrate'); if (Auth::attempt(['email' => env('USER_EMAIL'), 'password' => env('USER_PASSWORD')])) { // Authentication passed... + + $file_location = base_path() . '/.env'; + $default = "\nLARALUM_INSTALLED=true"; + file_put_contents($file_location,$default, FILE_APPEND); + $url = route('Laralum::dashboard'); return redirect()->intended($url)->with('success', trans('laralum.welcome_to_laralum')); } else{ diff --git a/app/Http/Controllers/Laralum/Laralum.php b/app/Http/Controllers/Laralum/Laralum.php index a4b64b6..80f64e1 100644 --- a/app/Http/Controllers/Laralum/Laralum.php +++ b/app/Http/Controllers/Laralum/Laralum.php @@ -35,7 +35,7 @@ public static function version() { return Laralum::settings()->laralum_version; } - + public static function websiteTitle() { return Laralum::settings()->website_title; @@ -337,11 +337,10 @@ public static function imageFormats() public static function checkInstalled() { - if(Schema::hasTable('users') and Schema::hasTable('roles') and Schema::hasTable('permissions') and Schema::hasTable('settings') and Schema::hasTable('blogs') and Schema::hasTable('posts') and Schema::hasTable('documents')) { + if(env('LARALUM_INSTALLED', false)){ return true; - } else { - return false; } + return false; } public static function checkDocumentOwner($type, $data){ diff --git a/app/Http/Middleware/Laralum/Authenticate.php b/app/Http/Middleware/Laralum/Authenticate.php index 3c6a39e..3564c61 100644 --- a/app/Http/Middleware/Laralum/Authenticate.php +++ b/app/Http/Middleware/Laralum/Authenticate.php @@ -17,12 +17,13 @@ class Authenticate */ public function handle($request, Closure $next) { - if(Auth::check()) { - Laralum::mustBeAdmin(Laralum::loggedInUser()); - return $next($request); - - } else { - return redirect('/')->with('error', 'You are not logged in'); + if(Laralum::checkInstalled()) { + if(Auth::check()) { + Laralum::mustBeAdmin(Laralum::loggedInUser()); + } else { + return redirect('/')->with('error', 'You are not logged in'); + } } + return $next($request); } } diff --git a/app/Http/Middleware/Laralum/Base.php b/app/Http/Middleware/Laralum/Base.php index 281cdce..578f1f8 100644 --- a/app/Http/Middleware/Laralum/Base.php +++ b/app/Http/Middleware/Laralum/Base.php @@ -18,33 +18,35 @@ class Base */ public function handle($request, Closure $next) { - # Check if the user is activated - if(Auth::check()) { + if(Laralum::checkInstalled()) { + # Check if the user is activated + if(Auth::check()) { + + $user = Laralum::loggedInuser(); + + if(!$user->active) { + if(Laralum::currentURL() != url('/logout')) { + if (strpos(Laralum::currentURL(), route('Laralum::activate_form')) !== false) { + // Seems to be ok + } else { + return redirect()->route('Laralum::activate_form'); + } + } - $user = Laralum::loggedInuser(); + } - if(!$user->active) { - if(Laralum::currentURL() != url('/logout')) { - if (strpos(Laralum::currentURL(), route('Laralum::activate_form')) !== false) { - // Seems to be ok - } else { - return redirect()->route('Laralum::activate_form'); + if($user->banned and Laralum::currentURL() != route('Laralum::banned')) { + if(Laralum::currentURL() != url('/logout')) { + return redirect()->route('Laralum::banned'); } } - } - - if($user->banned and Laralum::currentURL() != route('Laralum::banned')) { - if(Laralum::currentURL() != url('/logout')) { - return redirect()->route('Laralum::banned'); + # Set App Locale + if($user->locale) { + App::setLocale($user->locale); } - } - # Set App Locale - if($user->locale) { - App::setLocale($user->locale); } - } return $next($request); diff --git a/readme.md b/readme.md index 5db38b8..7f8816d 100644 --- a/readme.md +++ b/readme.md @@ -1,9 +1,27 @@ -# Laralum 2.0 +# Laravel PHP Framework -Since it's a new version, there'll be new docs, so stay aware of that +[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) +[![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework) +[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) +[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) +[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework) -## Installation +Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching. -``` -composer create-project erik/laralum ProjectName -``` +Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked. + +## Official Documentation + +Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs). + +## Contributing + +Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). + +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. + +## License + +The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT). diff --git a/routes/web.php b/routes/web.php index 798eee8..24b030f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -58,11 +58,6 @@ - - - - - /* +---------------------------------------------------------------------------+ | Laralum Routes |