2015-12-06 18:58:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Middleware;
|
|
|
|
|
2017-10-29 17:37:25 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Auth\AuthManager;
|
2015-12-06 18:58:49 +00:00
|
|
|
|
|
|
|
class RedirectIfAuthenticated
|
|
|
|
{
|
2017-10-29 17:37:25 +00:00
|
|
|
/**
|
|
|
|
* RedirectIfAuthenticated constructor.
|
|
|
|
*/
|
2022-10-14 17:59:20 +01:00
|
|
|
public function __construct(private AuthManager $authManager)
|
2017-10-29 17:37:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-06 18:58:49 +00:00
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*/
|
2023-02-23 19:30:16 +00:00
|
|
|
public function handle(Request $request, \Closure $next, string $guard = null): mixed
|
2015-12-06 18:58:49 +00:00
|
|
|
{
|
2017-10-29 17:37:25 +00:00
|
|
|
if ($this->authManager->guard($guard)->check()) {
|
2017-11-03 23:16:49 +00:00
|
|
|
return redirect()->route('index');
|
2015-12-06 18:58:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|