Files
laravel-manager/src/Http/Middleware/Authenticate.php
T
Matthijs Iriks 60ad85a621
PR CI / ledger (pull_request) Successful in 3s
PR CI / flow (pull_request) Successful in 4s
PR CI / ui (pull_request) Successful in 17s
PR CI / test (lowest) (pull_request) Successful in 45s
PR CI / test (stable) (pull_request) Successful in 48s
PR CI / security (pull_request) Successful in 54s
PR CI / pr-ci (pull_request) Successful in 1s
PR CI / release-automerge (pull_request) Successful in 3s
Let route names and tables move, and add manager:import
2026-12-04 05:08:08 +01:00

22 lines
652 B
PHP

<?php
namespace IriksIT\Manager\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use IriksIT\Manager\Support\Names;
/** `auth`, but a visitor goes to the login of the host app when it has one and to the manager's own login when not. */
class Authenticate extends Middleware
{
protected function redirectTo(Request $request): ?string
{
if ($request->expectsJson()) {
return null;
}
return Route::has('login') ? route('login') : (Route::has(Names::route('login')) ? route(Names::route('login')) : null);
}
}