MCPcopy Create free account
hub / github.com/CoderOpen/waimai / UserAuth

Class UserAuth

app/Http/Middleware/ChiHe/UserAuth.php:15–36  ·  view source on GitHub ↗

/ 注意,我们要继承的是 jwt 的 BaseMiddleware

Source from the content-addressed store, hash-verified

13
14//// 注意,我们要继承的是 jwt 的 BaseMiddleware
15class UserAuth extends BaseMiddleware
16{
17 /**
18 * Handle an incoming request.
19 *
20 * @param \Illuminate\Http\Request $request
21 * @param \Closure $next
22 *
23 * @return mixed
24 */
25
26 public function handle($request, Closure $next)
27 {
28 if (!Auth::guard('chi_he')->check()) {
29 return response()->json(['code' => 403, 'msg' => 'please login', 'data' => [],]);
30 }
31 $user = Auth::guard('chi_he')->user();
32 $request->offsetSet('user_id', $user->id);
33 $request->offsetSet('open_id', $user->open_id);
34 return $next($request);
35 }
36}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected