hypothetical/app/Http/Middleware/RedirectIfAuthenticated.php

28 lines
582 B
PHP
Raw Normal View History

<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
2016-01-03 23:55:13 -05:00
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
2016-01-03 23:55:13 -05:00
* @param string|null $guard
* @return mixed
*/
2016-01-03 23:55:13 -05:00
public function handle($request, Closure $next, $guard = null)
{
2016-01-03 23:55:13 -05:00
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
return $next($request);
}
}