perf: ldap测试登录提示优化&上产文件名长度限制

pull/12348/head
wangruidong 2023-12-15 17:10:51 +08:00 committed by Bryan
parent d92736e624
commit 6955a3db11
3 changed files with 5 additions and 5 deletions

View File

@ -52,7 +52,7 @@ class JobSerializer(ResourceLabelsMixin, BulkOrgResourceModelSerializer, PeriodT
class FileSerializer(serializers.Serializer):
files = serializers.FileField(allow_empty_file=True)
files = serializers.FileField(allow_empty_file=False, max_length=128)
class Meta:
ref_name = "JobFileSerializer"

View File

@ -649,7 +649,7 @@ class LDAPTestUtil(object):
def _test_before_login_check(self, username, password):
from settings.ws import CACHE_KEY_LDAP_TEST_CONFIG_TASK_STATUS, TASK_STATUS_IS_OVER
if cache.get(CACHE_KEY_LDAP_TEST_CONFIG_TASK_STATUS) != TASK_STATUS_IS_OVER:
if not cache.get(CACHE_KEY_LDAP_TEST_CONFIG_TASK_STATUS):
raise self.LDAPBeforeLoginCheckError(_('Please test the connection first'))
backend = LDAPAuthorizationBackend()

View File

@ -161,8 +161,8 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer):
return cache.get(task_key) == TASK_STATUS_IS_OVER
@staticmethod
def set_task_status_over(task_key):
cache.set(task_key, TASK_STATUS_IS_OVER, 120)
def set_task_status_over(task_key, ttl=120):
cache.set(task_key, TASK_STATUS_IS_OVER, ttl)
@staticmethod
def set_task_msg(task_key, ok, msg):
@ -192,7 +192,7 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer):
username = serializer.validated_data['username']
password = serializer.validated_data['password']
ok, msg = LDAPTestUtil().test_login(username, password)
self.set_task_status_over(CACHE_KEY_LDAP_TEST_LOGIN_TASK_STATUS)
self.set_task_status_over(CACHE_KEY_LDAP_TEST_LOGIN_TASK_STATUS, 3)
self.set_task_msg(CACHE_KEY_LDAP_TEST_LOGIN_MSG, ok, msg)
def run_sync_user(self, data):