mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-15 10:04:13 -08:00
4d9e85026a
Signed-off-by: snipe <snipe@snipe.net>
41 lines
859 B
PHP
41 lines
859 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\Setting;
|
|
use Closure;
|
|
|
|
class CheckForSetup
|
|
{
|
|
|
|
protected $except = [
|
|
'_debugbar*',
|
|
'health'
|
|
];
|
|
|
|
public function handle($request, Closure $next, $guard = null)
|
|
{
|
|
|
|
/**
|
|
* Skip this middleware for the debugbar and health check
|
|
*/
|
|
if ($request->is($this->except)) {
|
|
return $next($request);
|
|
}
|
|
|
|
if (Setting::setupCompleted()) {
|
|
if ($request->is('setup*')) {
|
|
return redirect(config('app.url'));
|
|
} else {
|
|
return $next($request);
|
|
}
|
|
} else {
|
|
if (! ($request->is('setup*')) && ! ($request->is('.env'))) {
|
|
return redirect(config('app.url').'/setup');
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|
|
}
|