From 58fd578ddd1230f48fe1574e510723cecc7c8d54 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 12 Oct 2023 20:04:28 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=B5=84=E4=BA=A7=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=B7=BB=E5=8A=A0=E8=B4=A6=E5=8F=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20(#11826)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/acls/notifications.py | 4 +++- apps/acls/templates/acls/asset_login_reminder.html | 1 + apps/authentication/api/connection_token.py | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/acls/notifications.py b/apps/acls/notifications.py index 5d3c59e13..cf19b7a51 100644 --- a/apps/acls/notifications.py +++ b/apps/acls/notifications.py @@ -41,9 +41,10 @@ class UserLoginReminderMsg(UserMessage): class AssetLoginReminderMsg(UserMessage): subject = _('Asset login reminder') - def __init__(self, user, asset: Asset, login_user: User): + def __init__(self, user, asset: Asset, login_user: User, account_username): self.asset = asset self.login_user = login_user + self.account_username = account_username super().__init__(user) def get_html_msg(self) -> dict: @@ -51,6 +52,7 @@ class AssetLoginReminderMsg(UserMessage): 'recipient': self.user.username, 'username': self.login_user.username, 'asset': str(self.asset), + 'account': self.account_username, } message = render_to_string('acls/asset_login_reminder.html', context) diff --git a/apps/acls/templates/acls/asset_login_reminder.html b/apps/acls/templates/acls/asset_login_reminder.html index 9a30cda49..8d63a2ff6 100644 --- a/apps/acls/templates/acls/asset_login_reminder.html +++ b/apps/acls/templates/acls/asset_login_reminder.html @@ -4,6 +4,7 @@
{% trans 'Username' %}: [{{ username }}]
{% trans 'Assets' %}: [{{ asset }}]
+{% trans 'Account' %}: [{{ account }}]
{% trans 'The user has just successfully logged into the asset. Please ensure that this is an authorized operation. If you suspect that this is an unauthorized access, please take appropriate measures immediately.' %}
diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index b0756d4aa..6eb371827 100644 --- a/apps/authentication/api/connection_token.py +++ b/apps/authentication/api/connection_token.py @@ -419,9 +419,10 @@ class ConnectionTokenViewSet(ExtraActionApiMixin, RootOrgViewMixin, JMSModelView reviewers = acl.reviewers.all() if not reviewers: return + account_username = account.username self._record_operate_log(acl, asset) for reviewer in reviewers: - AssetLoginReminderMsg(reviewer, asset, user).publish_async() + AssetLoginReminderMsg(reviewer, asset, user, account_username).publish_async() class SuperConnectionTokenViewSet(ConnectionTokenViewSet):