zzb 1 yıl önce
ebeveyn
işleme
4a89c1df52
2 değiştirilmiş dosya ile 3 ekleme ve 2 silme
  1. 1 0
      app/api/config.php
  2. 2 2
      app/api/controller/base/Permissions.php

+ 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配置
 ];

+ 2 - 2
app/api/controller/base/Permissions.php

@@ -50,7 +50,7 @@ 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;
@@ -109,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');
 
         //设置登入状态