BookStack/app/Http/Middleware/Authenticate.php

26 lines
490 B
PHP
Raw Normal View History

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