Astral-nook/app/Http/Middleware/RedirectIfAuthenticated.php
Matthew Penner cbcf62086f
Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2022-10-14 10:59:20 -06:00

29 lines
596 B
PHP

<?php
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Auth\AuthManager;
class RedirectIfAuthenticated
{
/**
* RedirectIfAuthenticated constructor.
*/
public function __construct(private AuthManager $authManager)
{
}
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next, string $guard = null): mixed
{
if ($this->authManager->guard($guard)->check()) {
return redirect()->route('index');
}
return $next($request);
}
}