mirror of https://github.com/jumpserver/jumpserver
[Update] Reponse status code from 401 to 400
parent
8c0bf0b71b
commit
9a39ccd37d
|
@ -72,13 +72,13 @@ class MailTestingAPI(APIView):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return Response({"error": str(resp)}, status=401)
|
return Response({"error": str(resp)}, status=400)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return Response({"error": str(e)}, status=401)
|
return Response({"error": str(e)}, status=400)
|
||||||
return Response({"msg": self.success_message.format(email_recipient)})
|
return Response({"msg": self.success_message.format(email_recipient)})
|
||||||
else:
|
else:
|
||||||
return Response({"error": str(serializer.errors)}, status=401)
|
return Response({"error": str(serializer.errors)}, status=400)
|
||||||
|
|
||||||
|
|
||||||
class LDAPTestingConfigAPI(APIView):
|
class LDAPTestingConfigAPI(APIView):
|
||||||
|
@ -88,10 +88,10 @@ class LDAPTestingConfigAPI(APIView):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
serializer = self.serializer_class(data=request.data)
|
serializer = self.serializer_class(data=request.data)
|
||||||
if not serializer.is_valid():
|
if not serializer.is_valid():
|
||||||
return Response({"error": str(serializer.errors)}, status=401)
|
return Response({"error": str(serializer.errors)}, status=400)
|
||||||
config = self.get_ldap_config(serializer)
|
config = self.get_ldap_config(serializer)
|
||||||
ok, msg = LDAPTestUtil(config).test_config()
|
ok, msg = LDAPTestUtil(config).test_config()
|
||||||
status = 200 if ok else 401
|
status = 200 if ok else 400
|
||||||
return Response(msg, status=status)
|
return Response(msg, status=status)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -124,11 +124,11 @@ class LDAPTestingLoginAPI(APIView):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
serializer = self.serializer_class(data=request.data)
|
serializer = self.serializer_class(data=request.data)
|
||||||
if not serializer.is_valid():
|
if not serializer.is_valid():
|
||||||
return Response({"error": str(serializer.errors)}, status=401)
|
return Response({"error": str(serializer.errors)}, status=400)
|
||||||
username = serializer.validated_data['username']
|
username = serializer.validated_data['username']
|
||||||
password = serializer.validated_data['password']
|
password = serializer.validated_data['password']
|
||||||
ok, msg = LDAPTestUtil().test_login(username, password)
|
ok, msg = LDAPTestUtil().test_login(username, password)
|
||||||
status = 200 if ok else 401
|
status = 200 if ok else 400
|
||||||
return Response(msg, status=status)
|
return Response(msg, status=status)
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,14 +236,14 @@ class LDAPUserImportAPI(APIView):
|
||||||
try:
|
try:
|
||||||
users = self.get_ldap_users()
|
users = self.get_ldap_users()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Response({'error': str(e)}, status=401)
|
return Response({'error': str(e)}, status=400)
|
||||||
|
|
||||||
if users is None:
|
if users is None:
|
||||||
return Response({'msg': _('Get ldap users is None')}, status=401)
|
return Response({'msg': _('Get ldap users is None')}, status=400)
|
||||||
|
|
||||||
errors = LDAPImportUtil().perform_import(users)
|
errors = LDAPImportUtil().perform_import(users)
|
||||||
if errors:
|
if errors:
|
||||||
return Response({'errors': errors}, status=401)
|
return Response({'errors': errors}, status=400)
|
||||||
|
|
||||||
count = users if users is None else len(users)
|
count = users if users is None else len(users)
|
||||||
return Response({'msg': _('Imported {} users successfully').format(count)})
|
return Response({'msg': _('Imported {} users successfully').format(count)})
|
||||||
|
@ -276,6 +276,7 @@ class PublicSettingApi(generics.RetrieveAPIView):
|
||||||
|
|
||||||
|
|
||||||
class SettingsApi(generics.RetrieveUpdateAPIView):
|
class SettingsApi(generics.RetrieveUpdateAPIView):
|
||||||
|
permission_classes = (IsSuperUser,)
|
||||||
serializer_class = SettingsSerializer
|
serializer_class = SettingsSerializer
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
|
|
|
@ -75,7 +75,7 @@ class SecuritySettingSerializer(serializers.Serializer):
|
||||||
SECURITY_SERVICE_ACCOUNT_REGISTRATION = serializers.BooleanField(required=True)
|
SECURITY_SERVICE_ACCOUNT_REGISTRATION = serializers.BooleanField(required=True)
|
||||||
SECURITY_LOGIN_LIMIT_COUNT = serializers.IntegerField(min_value=3, max_value=99999, required=True)
|
SECURITY_LOGIN_LIMIT_COUNT = serializers.IntegerField(min_value=3, max_value=99999, required=True)
|
||||||
SECURITY_LOGIN_LIMIT_TIME = serializers.IntegerField(min_value=5, max_value=99999, required=True)
|
SECURITY_LOGIN_LIMIT_TIME = serializers.IntegerField(min_value=5, max_value=99999, required=True)
|
||||||
SECURITY_MAX_IDLE_TIME = serializers.IntegerField(min_value=5, max_value=99999, required=False)
|
SECURITY_MAX_IDLE_TIME = serializers.IntegerField(min_value=1, max_value=99999, required=False)
|
||||||
SECURITY_PASSWORD_EXPIRATION_TIME = serializers.IntegerField(min_value=1, max_value=99999, required=True)
|
SECURITY_PASSWORD_EXPIRATION_TIME = serializers.IntegerField(min_value=1, max_value=99999, required=True)
|
||||||
SECURITY_PASSWORD_MIN_LENGTH = serializers.IntegerField(min_value=6, max_value=30, required=True)
|
SECURITY_PASSWORD_MIN_LENGTH = serializers.IntegerField(min_value=6, max_value=30, required=True)
|
||||||
SECURITY_PASSWORD_UPPER_CASE = serializers.BooleanField(required=False)
|
SECURITY_PASSWORD_UPPER_CASE = serializers.BooleanField(required=False)
|
||||||
|
|
Loading…
Reference in New Issue