snipe-it/app/Http/Middleware/CheckForSetup.php

41 lines
859 B
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
namespace App\Http\Middleware;
2016-05-14 16:09:00 -07:00
use App\Models\Setting;
use Closure;
2016-03-25 01:18:05 -07:00
class CheckForSetup
{
protected $except = [
'_debugbar*',
'health'
];
2016-03-25 01:18:05 -07:00
public function handle($request, Closure $next, $guard = null)
{
/**
* Skip this middleware for the debugbar and health check
*/
if ($request->is($this->except)) {
2016-11-29 01:19:05 -08:00
return $next($request);
}
2016-06-22 12:27:41 -07:00
if (Setting::setupCompleted()) {
if ($request->is('setup*')) {
return redirect(config('app.url'));
2016-05-14 16:09:00 -07:00
} else {
return $next($request);
2016-06-22 12:27:41 -07:00
}
} else {
if (! ($request->is('setup*')) && ! ($request->is('.env'))) {
return redirect(config('app.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
}
}