diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 6eb371827..f51351b67 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -22,6 +22,7 @@ from common.utils import random_string, get_logger, get_request_ip from common.utils.django import get_request_os from common.utils.http import is_true, is_false from orgs.mixins.api import RootOrgViewMixin +from orgs.utils import tmp_to_org from perms.models import ActionChoices from terminal.connect_methods import NativeClient, ConnectMethodUtil from terminal.models import EndpointRule, Endpoint @@ -383,13 +384,14 @@ class ConnectionTokenViewSet(ExtraActionApiMixin, RootOrgViewMixin, JMSModelView @staticmethod def _record_operate_log(acl, asset): from audits.handler import create_or_update_operate_log - after = {str(_('Assets')): str(asset)} - object_name = acl._meta.object_name - resource_type = acl._meta.verbose_name - create_or_update_operate_log( - acl.action, resource_type, resource=acl, - after=after, object_name=object_name - ) + with tmp_to_org(asset.org_id): + after = {str(_('Assets')): str(asset)} + object_name = acl._meta.object_name + resource_type = acl._meta.verbose_name + create_or_update_operate_log( + acl.action, resource_type, resource=acl, + after=after, object_name=object_name + ) def _validate_acl(self, user, asset, account): from acls.models import LoginAssetACL