Files
panel-pelican-dev/app/Http/Middleware/RedirectIfAuthenticated.php

21 lines
453 B
PHP
Raw Normal View History

<?php
2024-03-12 22:39:16 -04:00
namespace App\Http\Middleware;
2017-10-29 12:37:25 -05:00
use Illuminate\Http\Request;
use Illuminate\Auth\AuthManager;
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);
}
}