BookStack/app/Http/Middleware/Authenticate.php
Dan Brown 3de55ee645
Linked new API token system into middleware
Base logic in place but needs review and refactor to see if can better
fit into Laravel using 'Guard' system. Currently has issues due to
cookies in use from active session on API.
2019-12-30 02:16:07 +00:00

26 lines
490 B
PHP

<?php
namespace BookStack\Http\Middleware;
use BookStack\Http\Request;
use Closure;
class Authenticate
{
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next)
{
if (!hasAppAccess()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest(url('/login'));
}
}
return $next($request);
}
}