From 75ea0079a23dba0b503b16469ca3262e63ab1b4b Mon Sep 17 00:00:00 2001
From: ibuler <ibuler@qq.com>
Date: Tue, 8 Apr 2025 18:43:07 +0800
Subject: [PATCH] perf: update ad domain

---
 apps/authentication/models/connection_token.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/apps/authentication/models/connection_token.py b/apps/authentication/models/connection_token.py
index 7f450b8ca..2c4b120e4 100644
--- a/apps/authentication/models/connection_token.py
+++ b/apps/authentication/models/connection_token.py
@@ -256,6 +256,8 @@ class ConnectionToken(JMSOrgBaseModel):
             return True
 
     def set_ad_domain_if_need(self, account):
+        if not self.protocol == 'rdp':
+            return
         rdp = self.asset.platform.protocols.filter(name='rdp').first()
         if not rdp or not rdp.setting:
             return
@@ -279,9 +281,8 @@ class ConnectionToken(JMSOrgBaseModel):
             account = self.asset.all_valid_accounts.filter(id=self.account).first()
             if not account.secret and self.input_secret:
                 account.secret = self.input_secret
+            self.set_ad_domain_if_need(account)
 
-            if self.protocol == 'rdp':
-                self.set_ad_domain_if_need(account)
         return account
 
     @lazyproperty