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