Browse Source

Merge branch 'master' of http://59.57.98.130:3000/jjhc/reservation_admin

linwu 2 years ago
parent
commit
47296bb14f

+ 1 - 0
app/api/config.php

@@ -9,4 +9,5 @@
 //配置文件
 return [
     'exception_handle' => 'app\api\exception\ExceptionHandler',// 异常处理handle类,默认使用 \think\exception\Handle
+    'JWT_KEY' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9',//jwt配置
 ];

+ 6 - 12
app/api/controller/base/Permissions.php

@@ -50,31 +50,25 @@ class Permissions extends Base
         //check x-token
         try {
             JWT::$leeway = 60;
-            $jwt_key = system_salt();
+            $jwt_key = config('JWT_KEY');
             $decoded = JWT::decode($jwt, new Key($jwt_key, 'HS256'));
 
             $arr = (array)$decoded;
             if (!isset($arr['exp']) || $arr['exp'] < time()) {
-                self::clear_session();
-                throw new \think\Exception('登入超时,请重新登录');
+                throw new \think\Exception('Expired token');
             } else {
                 //鉴权成功
                 $this->userId = $arr['data']->userId;
                 $loginTime = $arr['data']->loginTime;
                 $exptime = $arr['exp'];
-                //限制账号多次登入
-//                if ($this->getUser()->getData('login_time') > $loginTime) {
-//                    $this->clear_session();
-//                    throw new \think\Exception('您的账号已经在其它地方登入');
-//                }
                 // 每次刷新jwt,loginTime要保持不变
                 self::createJwt($this->userId, $loginTime, 3600, $exptime);
                 return;
             }
         } catch (Exception $e) {
-            if ($e instanceof HttpResponseException) {
-                $this->json_error($e->getResponse()->getData()['msg']);
-            }
+//            if ($e instanceof HttpResponseException) {
+//                $this->json_error($e->getResponse()->getData()['msg']);
+//            }
             switch ($e->getMessage()) {
                 case "Expired token":
                     self::clear_session();
@@ -115,7 +109,7 @@ class Permissions extends Base
             'data' => $data //不要存放隐私信息,jwt可以保证内容不被修改,但可以被解码查看内容
         ];
         // 得到jwt
-        $jwt_key = system_salt();
+        $jwt_key = config('JWT_KEY');
         $jwt = JWT::encode($token, $jwt_key, 'HS256');
 
         //设置登入状态

File diff suppressed because it is too large
+ 128 - 0
app/install/data/test_yuye_jiangz_20230511_113113.sql


Some files were not shown because too many files changed in this diff