| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 02:31:09 +08:00
										 |  |  | namespace BookStack\Http\Middleware; | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | use Closure; | 
					
						
							|  |  |  | use Illuminate\Contracts\Auth\Guard; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class RedirectIfAuthenticated | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * The Guard implementation. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var Guard | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     protected $auth; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Create a new filter instance. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-09-05 03:40:36 +08:00
										 |  |  |      * @param  Guard $auth | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  |      * @return void | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function __construct(Guard $auth) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->auth = $auth; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Handle an incoming request. | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2015-09-05 03:40:36 +08:00
										 |  |  |      * @param  \Illuminate\Http\Request $request | 
					
						
							|  |  |  |      * @param  \Closure                 $next | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  |      * @return mixed | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function handle($request, Closure $next) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ($this->auth->check()) { | 
					
						
							| 
									
										
										
										
											2015-09-05 03:40:36 +08:00
										 |  |  |             return redirect('/'); | 
					
						
							| 
									
										
										
										
											2015-07-13 03:01:42 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $next($request); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |