diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index bc79d26a2..076767946 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -544,12 +544,12 @@ class SuperConnectionTokenViewSet(ConnectionTokenViewSet): @action(methods=['DELETE', 'POST'], detail=False, url_path='applet-account/release') def release_applet_account(self, *args, **kwargs): - account_id = self.request.data.get('id') - released = ConnectionToken.release_applet_account(account_id) + lock_key = self.request.data.get('id') + released = ConnectionToken.release_applet_account(lock_key) if released: - logger.debug('Release applet account success: {}'.format(account_id)) + logger.debug('Release applet account success: {}'.format(lock_key)) return Response({'msg': 'released'}) else: - logger.error('Release applet account error: {}'.format(account_id)) + logger.error('Release applet account error: {}'.format(lock_key)) return Response({'error': 'not found or expired'}, status=400) diff --git a/apps/authentication/models/connection_token.py b/apps/authentication/models/connection_token.py index 6cd5648db..2ef28eab1 100644 --- a/apps/authentication/models/connection_token.py +++ b/apps/authentication/models/connection_token.py @@ -199,28 +199,23 @@ class ConnectionToken(JMSOrgBaseModel): if not host_account: raise JMSException({'error': 'No host account available'}) - host, account, lock_key, ttl = bulk_get(host_account, ('host', 'account', 'lock_key', 'ttl')) + host, account, lock_key = bulk_get(host_account, ('host', 'account', 'lock_key')) gateway = host.domain.select_gateway() if host.domain else None data = { - 'id': account.id, + 'id': lock_key, 'applet': applet, 'host': host, 'gateway': gateway, 'account': account, 'remote_app_option': self.get_remote_app_option() } - token_account_relate_key = f'token_account_relate_{account.id}' - cache.set(token_account_relate_key, lock_key, ttl) return data @staticmethod - def release_applet_account(account_id): - token_account_relate_key = f'token_account_relate_{account_id}' - lock_key = cache.get(token_account_relate_key) + def release_applet_account(lock_key): if lock_key: cache.delete(lock_key) - cache.delete(token_account_relate_key) return True @lazyproperty diff --git a/apps/terminal/models/applet/applet.py b/apps/terminal/models/applet/applet.py index c018275ac..3110b506f 100644 --- a/apps/terminal/models/applet/applet.py +++ b/apps/terminal/models/applet/applet.py @@ -299,8 +299,7 @@ class Applet(JMSBaseModel): res = { 'host': host, 'account': account, - 'lock_key': lock_key, - 'ttl': ttl + 'lock_key': lock_key } logger.debug('Select host and account: {}'.format(res)) return res