Respond with the correct responses on error

This commit is contained in:
Graham Campbell
2015-06-17 14:06:18 +01:00
parent 0acc419bab
commit 8c4653c18c
16 changed files with 10 additions and 342 deletions

View File

@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
class Authenticate
{
@@ -44,11 +45,7 @@ class Authenticate
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
throw new UnauthorizedHttpException();
}
return $next($request);