Skip to content

Commit fcaac9c

Browse files
committed
feat: update account lock logic and modify workspace ID requirements in role settings
1 parent d9a6551 commit fcaac9c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

apps/users/api/user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def get_data(self):
2525
class RoleSettingRequestSerializer(serializers.Serializer):
2626
role_id = serializers.CharField(required=True, label=_('Role ID'))
2727
workspace_ids = serializers.ListField(
28-
child=serializers.CharField(required=True),
29-
required=True,
28+
child=serializers.CharField(required=False),
29+
required=False,
3030
label=_('Workspace IDs')
3131
)
3232

apps/users/serializers/login.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def login(instance):
106106

107107
if is_license_valid:
108108
# 检查账户是否被锁定
109-
if LoginSerializer._is_account_locked(username):
109+
if LoginSerializer._is_account_locked(username, failed_attempts):
110110
raise AppApiException(
111111
1005,
112112
_("This account has been locked for %s minutes, please try again later") % lock_time
@@ -146,8 +146,10 @@ def login(instance):
146146
return {'token': token}
147147

148148
@staticmethod
149-
def _is_account_locked(username: str) -> bool:
149+
def _is_account_locked(username: str, failed_attempts: int) -> bool:
150150
"""检查账户是否被锁定"""
151+
if failed_attempts == -1:
152+
return False
151153
lock_cache = cache.get(system_get_key(f'system_{username}_lock'), version=system_version)
152154
return bool(lock_cache)
153155

0 commit comments

Comments
 (0)