Skip to content

Commit

Permalink
Fixed database error before installation
Browse files Browse the repository at this point in the history
  • Loading branch information
ConsoleTVs committed Aug 31, 2016
1 parent fa7c349 commit 9b629ae
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 42 deletions.
9 changes: 7 additions & 2 deletions app/Http/Controllers/Laralum/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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{
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Controllers/Laralum/Laralum.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function version()
{
return Laralum::settings()->laralum_version;
}

public static function websiteTitle()
{
return Laralum::settings()->website_title;
Expand Down Expand Up @@ -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){
Expand Down
13 changes: 7 additions & 6 deletions app/Http/Middleware/Laralum/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
40 changes: 21 additions & 19 deletions app/Http/Middleware/Laralum/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 24 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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).
5 changes: 0 additions & 5 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@








/*
+---------------------------------------------------------------------------+
| Laralum Routes |
Expand Down

0 comments on commit 9b629ae

Please sign in to comment.