Skip to content

Commit

Permalink
fix(backend): 补充mongodb 不允许创建特殊账号 #8309
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 25427
  • Loading branch information
ygcyao authored and iSecloud committed Nov 29, 2024
1 parent b075199 commit 3b4f952
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ def check_username_valid(cls, account_type, user):

# 不允许使用特殊账户名称
special_account_names = ACCOUNT_RULES_MAP.get(account_type, [])
if user in special_account_names:
# 检查是否为MongoDB类型,并尝试分割用户名
second_part = None
if account_type == AccountType.MONGODB:
try:
first_part, second_part = user.split(".", 1)
except ValueError:
pass

if second_part in special_account_names or user in special_account_names:
raise serializers.ValidationError(_("不允许使用特殊账号名称[{}], 请重新更改账号名".format(user)))

@classmethod
Expand Down

0 comments on commit 3b4f952

Please sign in to comment.