mirror of https://github.com/jumpserver/jumpserver
				
				
				
			perf: 修改account密码加载
							parent
							
								
									5d373c0137
								
							
						
					
					
						commit
						c318762f82
					
				| 
						 | 
				
			
			@ -27,7 +27,6 @@ class AuthBook(BaseUser, AbsConnectivity):
 | 
			
		|||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
        self.auth_snapshot = {}
 | 
			
		||||
        self.load_auth()
 | 
			
		||||
 | 
			
		||||
    def get_or_systemuser_attr(self, attr):
 | 
			
		||||
        val = getattr(self, attr, None)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -141,6 +141,7 @@ class AuthMixin:
 | 
			
		|||
        else:
 | 
			
		||||
            authbooks.sort(key=lambda x: 1 if x.username == username else 0, reverse=True)
 | 
			
		||||
            authbook = authbooks[0]
 | 
			
		||||
        authbook.load_auth()
 | 
			
		||||
        self.password = authbook.password
 | 
			
		||||
        self.private_key = authbook.private_key
 | 
			
		||||
        self.public_key = authbook.public_key
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,6 +32,10 @@ class AccountSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
 | 
			
		|||
        queryset = queryset.prefetch_related('systemuser', 'asset')
 | 
			
		||||
        return queryset
 | 
			
		||||
 | 
			
		||||
    def to_representation(self, instance):
 | 
			
		||||
        instance.load_auth()
 | 
			
		||||
        return super().to_representation(instance)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class AccountSecretSerializer(AccountSerializer):
 | 
			
		||||
    class Meta(AccountSerializer.Meta):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,6 +81,7 @@ def test_account_connectivity_util(account, task_name):
 | 
			
		|||
    if not check_asset_can_run_ansible(account.asset):
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    account.load_auth()
 | 
			
		||||
    try:
 | 
			
		||||
        raw, summary = test_user_connectivity(
 | 
			
		||||
            task_name=task_name, asset=account.asset,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue