RedirectIfAuthenticated.php 519 Bytes
Newer Older
Graham Campbell committed
1 2 3
<?php

namespace App\Http\Middleware;
Taylor Otwell committed
4

Taylor Otwell committed
5
use Closure;
6
use Illuminate\Support\Facades\Auth;
Taylor Otwell committed
7

Taylor Otwell committed
8 9 10 11 12 13 14
class RedirectIfAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
15
     * @param  string|null  $guard
Taylor Otwell committed
16 17
     * @return mixed
     */
18
    public function handle($request, Closure $next, $guard = null)
Taylor Otwell committed
19
    {
20
        if (Auth::guard($guard)->check()) {
21
            return redirect('/');
Taylor Otwell committed
22
        }
Taylor Otwell committed
23

Taylor Otwell committed
24 25
        return $next($request);
    }
26
}