firefly-iii/app/Http/Middleware/RedirectIfAuthenticated.php

51 lines
905 B
PHP
Raw Normal View History

2015-02-05 21:52:16 -06:00
<?php namespace FireflyIII\Http\Middleware;
2015-02-05 21:39:52 -06:00
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\RedirectResponse;
2015-02-11 00:35:10 -06:00
/**
* Class RedirectIfAuthenticated
*
* @package FireflyIII\Http\Middleware
*/
class RedirectIfAuthenticated
{
2015-02-05 21:39:52 -06:00
2015-02-11 00:35:10 -06:00
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
2015-02-05 21:39:52 -06:00
2015-02-11 00:35:10 -06:00
/**
* Create a new filter instance.
*
* @param Guard $auth
*
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
2015-02-05 21:39:52 -06:00
2015-02-11 00:35:10 -06:00
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
2015-02-27 09:08:46 -06:00
return new RedirectResponse(url('/'));
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
}