Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com> Co-authored-by: Boy132 <Boy132@users.noreply.github.com> Co-authored-by: Lance Pioch <git@lance.sh>
22 lines
465 B
PHP
22 lines
465 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Auth\AuthManager;
|
|
|
|
readonly class RedirectIfAuthenticated
|
|
{
|
|
public function __construct(private AuthManager $authManager) {}
|
|
|
|
public function handle(Request $request, Closure $next, ?string $guard = null): mixed
|
|
{
|
|
if ($this->authManager->guard($guard)->check()) {
|
|
return redirect('/');
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|