相同的设备标识dice只保证一个auth-token生效,清除掉多余的同一个dice多余的auth-token
This commit is contained in:
@@ -8,6 +8,7 @@ use support\Response;
|
||||
use Tinywan\Jwt\JwtToken;
|
||||
use plugin\saiadmin\basic\OpenController;
|
||||
use app\api\util\ReturnCode;
|
||||
use app\api\cache\AuthTokenCache;
|
||||
|
||||
/**
|
||||
* API 鉴权 Token 接口
|
||||
@@ -57,7 +58,7 @@ class AuthTokenController extends OpenController
|
||||
return $this->fail('签名验证失败', ReturnCode::EMPTY_PARAMS);
|
||||
}
|
||||
|
||||
$exp = config('api.auth_token_exp', 86400);
|
||||
$exp = (int) config('api.auth_token_exp', 86400);
|
||||
$tokenResult = JwtToken::generateToken([
|
||||
'id' => 0,
|
||||
'plat' => 'api',
|
||||
@@ -65,6 +66,9 @@ class AuthTokenController extends OpenController
|
||||
'access_exp' => $exp,
|
||||
]);
|
||||
|
||||
// 同一设备只保留最新 token,覆盖后旧 token 失效
|
||||
AuthTokenCache::setDeviceToken($device, $tokenResult['access_token'], $exp);
|
||||
|
||||
return $this->success([
|
||||
'auth-token' => $tokenResult['access_token'],
|
||||
'expires_in' => $tokenResult['expires_in'],
|
||||
|
||||
Reference in New Issue
Block a user