2015-12-06 18:58:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
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
|
|
|
/**
|
2017-11-03 23:16:49 +00:00
|
|
|
* @var \Illuminate\Auth\AuthManager
|
2017-10-29 17:37:25 +00:00
|
|
|
*/
|
|
|
|
private $authManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* RedirectIfAuthenticated constructor.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Auth\AuthManager $authManager
|
|
|
|
*/
|
|
|
|
public function __construct(AuthManager $authManager)
|
|
|
|
{
|
|
|
|
$this->authManager = $authManager;
|
|
|
|
}
|
|
|
|
|
2015-12-06 18:58:49 +00:00
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
2017-08-22 04:10:48 +01:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2019-09-06 05:32:57 +01:00
|
|
|
* @param \Closure $next
|
|
|
|
* @param string|null $guard
|
2015-12-06 18:58:49 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
2017-10-29 17:37:25 +00:00
|
|
|
public function handle(Request $request, Closure $next, string $guard = null)
|
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);
|
|
|
|
}
|
|
|
|
}
|