Files
panel/app/Http/Middleware/RedirectIfAuthenticated.php

22 lines
465 B
PHP
Raw Permalink Normal View History

<?php
2024-03-12 22:39:16 -04:00
namespace App\Http\Middleware;
use Closure;
2017-10-29 12:37:25 -05:00
use Illuminate\Auth\AuthManager;
2025-09-24 13:34:19 +02:00
use Illuminate\Http\Request;
readonly class RedirectIfAuthenticated
{
public function __construct(private AuthManager $authManager) {}
2017-10-29 12:37:25 -05:00
public function handle(Request $request, Closure $next, ?string $guard = null): mixed
{
2017-10-29 12:37:25 -05:00
if ($this->authManager->guard($guard)->check()) {
return redirect('/');
}
return $next($request);
}
}