Created
August 17, 2016 14:03
-
-
Save Garbee/d53e3f16002b28f354ca588998a87468 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Contracts\Auth\Guard; | |
use Illuminate\Http\Request; | |
class RedirectIfAuthenticated | |
{ | |
/** @var Guard */ | |
private $auth; | |
/** | |
* RedirectIfAuthenticated constructor. | |
* @param Guard $auth | |
*/ | |
public function __construct(Guard $auth) | |
{ | |
$this->auth = $auth; | |
} | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle(Request $request, Closure $next) | |
{ | |
if ($this->auth->check()) { | |
return redirect('/home'); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment