2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Config;
|
|
|
|
use Route;
|
2016-05-14 15:05:20 -07:00
|
|
|
use Schema;
|
2016-03-25 19:26:22 -07:00
|
|
|
use App\Models\User;
|
2016-05-14 16:09:00 -07:00
|
|
|
use App\Models\Setting;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
class CheckForSetup
|
|
|
|
{
|
|
|
|
public function handle($request, Closure $next, $guard = null)
|
|
|
|
{
|
|
|
|
|
2018-11-01 19:59:50 -07:00
|
|
|
/**
|
|
|
|
* This is dumb
|
|
|
|
* @todo Check on removing this, not sure if it's still needed
|
|
|
|
*/
|
2016-11-29 01:19:05 -08:00
|
|
|
if ($request->is('_debugbar*')) {
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
2016-06-22 12:27:41 -07:00
|
|
|
if (Setting::setupCompleted()) {
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2016-06-22 12:27:41 -07:00
|
|
|
if ($request->is('setup*')) {
|
2016-12-15 16:41:36 -08:00
|
|
|
return redirect(url('/'));
|
2016-05-14 16:09:00 -07:00
|
|
|
} else {
|
|
|
|
return $next($request);
|
2016-06-22 12:27:41 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2016-06-22 12:27:41 -07:00
|
|
|
} else {
|
2016-10-25 19:51:13 -07:00
|
|
|
if (!($request->is('setup*')) && !($request->is('.env'))) {
|
2018-02-22 21:46:58 -08:00
|
|
|
return redirect(url('/').'/setup');
|
2016-05-14 16:09:00 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2016-06-22 12:27:41 -07:00
|
|
|
return $next($request);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|