forked from Laravel-Backpack/Base
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackpackAdmin.php
More file actions
31 lines (27 loc) · 789 Bytes
/
Copy pathBackpackAdmin.php
File metadata and controls
31 lines (27 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace Backpack\Base\app\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class BackpackAdmin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
*
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response(trans('backpack::base.unauthorized'), 401);
} else {
return redirect()->guest(config('backpack.base.route_prefix', 'admin').'/login');
}
}
return $next($request);
}
}