invoiceninja/app/Http/Middleware/RedirectIfAuthenticated.php

49 lines
818 B
PHP
Raw Normal View History

2015-03-12 10:44:39 +10:00
<?php namespace App\Http\Middleware;
2015-04-27 15:28:40 +03:00
use Session;
2015-03-12 10:44:39 +10:00
use Closure;
2015-04-20 17:34:23 +03:00
use App\Models\Client;
2015-03-12 10:44:39 +10:00
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Http\RedirectResponse;
class RedirectIfAuthenticated {
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
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, Closure $next)
{
2015-04-20 17:34:23 +03:00
if ($this->auth->check() && Client::scope()->count() > 0)
2015-03-12 10:44:39 +10:00
{
2015-04-27 15:28:40 +03:00
Session::reflash();
2015-04-02 16:06:16 +03:00
return new RedirectResponse(url('/dashboard'));
2015-03-12 10:44:39 +10:00
}
return $next($request);
}
}