Skip to content

Commit

Permalink
Handle the ajax case of unauthenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Sep 16, 2017
1 parent 5d84e8f commit b3a544d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Modules/Core/Http/Middleware/AdminMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Http\Response;
use Illuminate\Session\Store;
use Modules\User\Contracts\Authentication;

Expand Down Expand Up @@ -51,6 +52,9 @@ public function handle($request, \Closure $next)
{
// Check if the user is logged in
if (!$this->auth->check()) {
if ($request->ajax()) {
return response('Unauthenticated.', Response::HTTP_UNAUTHORIZED);
}
// Store the current uri in the session
$this->session->put('url.intended', $this->request->url());

Expand All @@ -61,7 +65,7 @@ public function handle($request, \Closure $next)
// Check if the user has access to the dashboard page
if (! $this->auth->hasAccess('dashboard.index')) {
// Show the insufficient permissions page
return $this->application->abort(403);
return $this->application->abort(Response::HTTP_FORBIDDEN);
}

return $next($request);
Expand Down

0 comments on commit b3a544d

Please sign in to comment.