2018-08-06 12:30:51 +00:00
|
|
|
<?php
|
|
|
|
namespace App\Http\Middleware;
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2022-08-10 09:18:10 +00:00
|
|
|
use App\Providers\RouteServiceProvider;
|
2015-07-19 06:49:24 +00:00
|
|
|
use Closure;
|
2018-08-06 12:30:51 +00:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2018-08-06 12:30:51 +00:00
|
|
|
class RedirectIfAuthenticated
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2022-08-10 09:18:10 +00:00
|
|
|
public function handle($request, Closure $next, $guards = [null])
|
2018-08-06 12:30:51 +00:00
|
|
|
{
|
2022-08-10 09:18:10 +00:00
|
|
|
$guards = empty($guards) ? [null] : $guards;
|
|
|
|
|
|
|
|
// if (Auth::guard($guard)->check()) {
|
|
|
|
// return redirect('/home');
|
|
|
|
// }
|
|
|
|
foreach ($guards as $guard) {
|
|
|
|
if (Auth::guard($guard)->check()) {
|
|
|
|
return redirect(RouteServiceProvider::HOME);
|
|
|
|
}
|
2018-08-06 12:30:51 +00:00
|
|
|
}
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2018-08-06 12:30:51 +00:00
|
|
|
return $next($request);
|
|
|
|
}
|
2015-07-19 06:49:24 +00:00
|
|
|
}
|