snipe-it/app/Http/Middleware/CheckForSetup.php
Martin Meredith e3e0d57f56 Minor code cleanup bits and bobs (#6805)
* Add IDE Helper files

* Cleanup imports

- Alphabetises imports
- Removes unused imports

* Add Platform requirements

* Move filling asset into block where asset exists

* Remove duplicate array keys
2019-03-13 20:12:03 -07:00

41 lines
797 B
PHP

<?php
namespace App\Http\Middleware;
use App\Models\Setting;
use Closure;
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);
}
}
}