Skip to content

Instantly share code, notes, and snippets.

@Garbee
Created August 17, 2016 14:03
Show Gist options
  • Save Garbee/d53e3f16002b28f354ca588998a87468 to your computer and use it in GitHub Desktop.
Save Garbee/d53e3f16002b28f354ca588998a87468 to your computer and use it in GitHub Desktop.
<?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