Conditions | 7 |
Paths | 5 |
Total Lines | 27 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function handle(Request $request, Closure $next, $guard = null) |
||
|
|||
23 | { |
||
24 | $guard = config('admin.guard'); |
||
25 | if (Auth::guard($guard)->guest()) { |
||
26 | if ($request->ajax() || $request->wantsJson()) { |
||
27 | return response('Unauthorized.', 401); |
||
28 | } else { |
||
29 | $url = route('admin.login'); |
||
30 | |||
31 | return redirect()->guest($url); |
||
32 | } |
||
33 | } |
||
34 | |||
35 | Auth::shouldUse($guard); |
||
36 | |||
37 | if (!$request->user()->can(Route::currentRouteName())) { |
||
38 | if ($request->ajax() || $request->wantsJson()) { |
||
39 | return response()->json(error('您没有权限执行此操作')); |
||
40 | } else { |
||
41 | $previousUrl = URL::previous(); |
||
42 | |||
43 | return response()->view('admin::errors.403', compact('previousUrl')); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | return $next($request); |
||
48 | } |
||
49 | } |
||
50 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.