snipe-it/app/Http/Middleware/CheckForSetup.php
Wes Hulette 88b1da4260 Added: Caching of settings (#6378)
* Fixed missing oauth tables during setup.

* Cache settings

Cache the setting to reduce unnecessary database calls
2018-11-01 19:59:50 -07:00

45 lines
853 B
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Config;
use Route;
use Schema;
use App\Models\User;
use App\Models\Setting;
class CheckForSetup
{
public function handle($request, Closure $next, $guard = null)
{
/**
* This is dumb
* @todo Check on removing this, not sure if it's still needed
*/
if ($request->is('_debugbar*')) {
return $next($request);
}
if (Setting::setupCompleted()) {
if ($request->is('setup*')) {
return redirect(url('/'));
} else {
return $next($request);
}
} else {
if (!($request->is('setup*')) && !($request->is('.env'))) {
return redirect(url('/').'/setup');
}
return $next($request);
}
}
}