header('Authorization'); if (empty($jwt)) { json(['code'=>-100,'msg'=>'请登陆'])->send(); exit; } $jwt = str_replace('bearer ', '', $jwt); try { JWT::$leeway = 60; //token的弹性有效时间 $decoded = JWT::decode($jwt, config('app.jwt_key'), ['HS256']); $arr = (array) $decoded; $aes = new Aes(config('app.jwt_key')); $queryData = $aes->decrypt($arr['data']); parse_str($queryData, $token); } catch (Exception $e) { json(['code'=>-100,'msg'=>'Token验证失败,请重新登录'])->send(); exit; } $this->employeeId = $token['employee_id']; $this->rootId = $token['root_id']; $this->uid = $token['uid']; } }