123456789101112131415161718192021222324252627282930 |
- <?php
- namespace app\middleware;
- use think\facade\Request;
- class Notken
- {
- public function handle($request, \Closure $next)
- {
- $authorization = Request::header("authorization");
- $authorization = explode(" ", $authorization);
- if (isset($authorization[1])){
- $authorizationInfo = explode(":", base64_decode($authorization[1]));
- $user = $authorizationInfo[0];
- $user_id = $authorizationInfo[1];
- $token = $authorizationInfo[2];
- Request::instance()->tokens = $token;
- Request::instance()->user_id = $user_id;
- Request::instance()->user = $user;
- }
- return $next($request);
- }
- }
|