mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 07:17:55 +01:00
29 lines
682 B
PHP
29 lines
682 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Providers\RouteServiceProvider;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class RedirectIfAuthenticated
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*/
|
|
public function handle(Request $request, Closure $next, string|null ...$guards): mixed
|
|
{
|
|
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
|
|
$guards = empty($guards) ? [null] : $guards;
|
|
|
|
foreach ($guards as $guard) {
|
|
if (Auth::guard($guard)->check()) {
|
|
return redirect(RouteServiceProvider::HOME);
|
|
}
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|