2016-01-08 09:00:57 -06:00
|
|
|
<?php
|
2016-02-05 05:08:25 -06:00
|
|
|
declare(strict_types = 1);
|
2016-01-08 09:00:57 -06:00
|
|
|
|
|
|
|
namespace FireflyIII\Http\Middleware;
|
2015-02-05 21:39:52 -06:00
|
|
|
|
|
|
|
use Closure;
|
2016-01-08 09:00:57 -06:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2015-02-05 21:39:52 -06:00
|
|
|
|
2016-01-09 01:20:55 -06:00
|
|
|
/**
|
|
|
|
* Class RedirectIfAuthenticated
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Http\Middleware
|
|
|
|
*/
|
2015-02-11 00:35:10 -06:00
|
|
|
class RedirectIfAuthenticated
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
2016-01-08 09:00:57 -06:00
|
|
|
* @param string|null $guard
|
2015-02-11 00:35:10 -06:00
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-01-08 09:00:57 -06:00
|
|
|
public function handle($request, Closure $next, $guard = null)
|
2015-02-11 00:35:10 -06:00
|
|
|
{
|
2016-01-08 09:00:57 -06:00
|
|
|
if (Auth::guard($guard)->check()) {
|
|
|
|
|
|
|
|
return redirect('/');
|
2015-02-11 00:35:10 -06:00
|
|
|
}
|
2015-02-05 21:39:52 -06:00
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
return $next($request);
|
|
|
|
}
|
2015-02-05 21:39:52 -06:00
|
|
|
}
|