|
@@ -50,31 +50,25 @@ class Permissions extends Base
|
|
|
|
|
|
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'];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
self::createJwt($this->userId, $loginTime, 3600, $exptime);
|
|
|
return;
|
|
|
}
|
|
|
} catch (Exception $e) {
|
|
|
- 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_key = system_salt();
|
|
|
+ $jwt_key = config('JWT_KEY');
|
|
|
$jwt = JWT::encode($token, $jwt_key, 'HS256');
|
|
|
|
|
|
|