Skip to content

A free open source IT asset/license management system

Check that the table exists

snipe1a14abed05fb
diff --git a/app/Http/Middleware/CheckForSetup.php b/app/Http/Middleware/CheckForSetup.php
index f0db94ddf7..03319cd110 100644
--- a/app/Http/Middleware/CheckForSetup.php
+++ b/app/Http/Middleware/CheckForSetup.php
@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
use Closure;
use Config;
use Route;
+use Schema;
use App\Models\User;
class CheckForSetup
@@ -13,12 +14,22 @@ class CheckForSetup
{
try {
- $usercount = User::withTrashed()->count();
- if (($usercount > 0) && (Route::is('setup*'))) {
- return redirect(config('app.url'));
+
+ $users_table_exists = Schema::hasTable('users');
+ $settings_table_exists = Schema::hasTable('settings');
+
+ if ($users_table_exists && $settings_table_exists) {
+ $usercount = User::withTrashed()->count();
+ if (($usercount > 0) && (Route::is('setup*'))) {
+ return redirect(config('app.url'));
+ } else {
+ return $next($request);
+ }
} else {
return $next($request);
}
+
+
} catch (\Exception $e) {
return $next($request);
}