12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use Illuminate\Contracts\Auth\Factory as Auth;
- class Authenticate
- {
-
- protected $auth;
-
- public function __construct(Auth $auth)
- {
- $this->auth = $auth;
- }
-
- public function handle($request, Closure $next, $guard = null)
- {
- if ($this->auth->guard($guard)->guest()) {
- $error = [
- 'message' => '请重新登录',
- 'code' => 401,
- ];
- return response()->json($error);
- }
- return $next($request);
- }
- }
|