mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 08:27:32 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			959 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			959 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Middleware;
 | |
| 
 | |
| use App\Models\Client;
 | |
| use Closure;
 | |
| use Illuminate\Contracts\Auth\Guard;
 | |
| use Illuminate\Http\RedirectResponse;
 | |
| use Illuminate\Http\Request;
 | |
| use Session;
 | |
| 
 | |
| /**
 | |
|  * Class RedirectIfAuthenticated.
 | |
|  */
 | |
| class RedirectIfAuthenticated
 | |
| {
 | |
|     /**
 | |
|      * The Guard implementation.
 | |
|      *
 | |
|      * @var Guard
 | |
|      */
 | |
|     protected $auth;
 | |
| 
 | |
|     /**
 | |
|      * Create a new filter instance.
 | |
|      *
 | |
|      * @param Guard $auth
 | |
|      */
 | |
|     public function __construct(Guard $auth)
 | |
|     {
 | |
|         $this->auth = $auth;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Handle an incoming request.
 | |
|      *
 | |
|      * @param Request $request
 | |
|      * @param Closure $next
 | |
|      *
 | |
|      * @return mixed
 | |
|      */
 | |
|     public function handle(Request $request, Closure $next)
 | |
|     {
 | |
|         if ($this->auth->check() && Client::scope()->count() > 0) {
 | |
|             Session::reflash();
 | |
| 
 | |
|             return new RedirectResponse(url('/dashboard'));
 | |
|         }
 | |
| 
 | |
|         return $next($request);
 | |
|     }
 | |
| }
 |