BookStack/app/Http/Middleware/Authenticate.php
Dan Brown b90033a730
Guest control: Cleaned methods involved in fetching/handling
- 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.
2023-09-16 13:18:35 +01:00

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);
}
}