BookStack/app/Http/Middleware/Authenticate.php

26 lines
475 B
PHP
Raw Normal View History

2015-07-13 03:01:42 +08:00
<?php
namespace BookStack\Http\Middleware;
2015-07-13 03:01:42 +08:00
use Closure;
use Illuminate\Http\Request;
2015-07-13 03:01:42 +08:00
class Authenticate
{
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next)
2015-07-13 03:01:42 +08:00
{
if (!user()->hasAppAccess()) {
2015-07-13 03:01:42 +08:00
if ($request->ajax()) {
return response('Unauthorized.', 401);
}
2021-08-21 22:49:40 +08:00
return redirect()->guest(url('/login'));
2015-07-13 03:01:42 +08:00
}
return $next($request);
}
}