mirror of
				https://github.com/BookStackApp/BookStack.git
				synced 2025-10-31 03:50:27 +03:00 
			
		
		
		
	- Moves guest user caching from User class to app container for simplicity. - Updates test to use simpler $this->users->guest() method for consistency. - Streamlined helpers to avoid function overlap for simplicity. - Extracted user profile dropdown while doing changes.
		
			
				
	
	
		
			26 lines
		
	
	
		
			475 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			475 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace BookStack\Http\Middleware;
 | |
| 
 | |
| use Closure;
 | |
| use Illuminate\Http\Request;
 | |
| 
 | |
| class Authenticate
 | |
| {
 | |
|     /**
 | |
|      * Handle an incoming request.
 | |
|      */
 | |
|     public function handle(Request $request, Closure $next)
 | |
|     {
 | |
|         if (!user()->hasAppAccess()) {
 | |
|             if ($request->ajax()) {
 | |
|                 return response('Unauthorized.', 401);
 | |
|             }
 | |
| 
 | |
|             return redirect()->guest(url('/login'));
 | |
|         }
 | |
| 
 | |
|         return $next($request);
 | |
|     }
 | |
| }
 |