fix: 修复没有 push_now 权限的用户可以在创建资产、创建账号中开启推送

pull/9496/head
Bai 2023-02-10 11:12:03 +08:00 committed by Jiangjie.Bai
parent c5b8ae6c9a
commit 4c96d6935a
1 changed files with 6 additions and 0 deletions

View File

@ -76,6 +76,12 @@ class AssetAccountSerializer(
'secret': {'write_only': True},
}
def validate_push_now(self, value):
request = self.context['request']
if not request.user.has_perms('assets.push_assetaccount'):
return False
return value
def validate_name(self, value):
if not value:
value = self.initial_data.get('username')