123456789101112131415161718192021222324252627282930 |
- <?php
- namespace App\Http\Middleware;
- use App\Services\AuthService;
- use Closure;
- use Illuminate\Support\Facades\Cache;
- class User
- {
-
- public function handle($request, Closure $next)
- {
- $authorization = $request->input('auth_data') ?? $request->header('authorization');
- if (!$authorization) abort(403, '未登录或登陆已过期');
- $user = AuthService::decryptAuthData($authorization);
- if (!$user) abort(403, '未登录或登陆已过期');
- $request->merge([
- 'user' => $user
- ]);
- return $next($request);
- }
- }
|