diff --git a/app/Http/Middleware/CheckConfigurationMiddleware.php b/app/Http/Middleware/CheckConfigurationMiddleware.php index b458aad51..f2aa00ebc 100644 --- a/app/Http/Middleware/CheckConfigurationMiddleware.php +++ b/app/Http/Middleware/CheckConfigurationMiddleware.php @@ -4,6 +4,7 @@ namespace App\Http\Middleware; use App\Models\User; use Closure; +use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -11,16 +12,26 @@ use Illuminate\Support\Facades\DB; class CheckConfigurationMiddleware { - public function handle(Request $request, Closure $next): Response|RedirectResponse + public function handle(Request $request, Closure $next): Response|RedirectResponse|JsonResponse { $checks = [ - empty(DB::connection()->getDatabaseName()) => 'setup.index', - empty(User::exists()) => 'setup.admin', + empty(DB::connection()->getDatabaseName()) => [ + 'redirect' => 'setup.index', + 'patterns' => [ + 'setup.index', + 'setup.test', + 'setup.save', + ], + ], + empty(User::exists()) => [ + 'redirect' => 'setup.admin', + 'patterns' => 'setup.admin*', + ], ]; foreach ($checks as $check => $route) { if ($check) { - return $request->routeIs($route) ? $next($request) : redirect()->route($route); + return $request->routeIs($route['patterns']) ? $next($request) : redirect()->route($route['redirect']); } }