mirror of https://github.com/jumpserver/jumpserver
feat: 增加人脸识别超时控制
parent
cfadbc164c
commit
f92c557235
|
@ -226,12 +226,20 @@ class MFAFaceMixin:
|
||||||
def is_context_finished(context):
|
def is_context_finished(context):
|
||||||
return context.get('is_finished', False)
|
return context.get('is_finished', False)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_context_success(context):
|
||||||
|
return context.get('success', False)
|
||||||
|
|
||||||
def get_face_code(self):
|
def get_face_code(self):
|
||||||
context = self.get_face_recognition_context()
|
context = self.get_face_recognition_context()
|
||||||
|
|
||||||
if not self.is_context_finished(context):
|
if not self.is_context_finished(context):
|
||||||
raise RuntimeError("Face recognition is not yet completed.")
|
raise RuntimeError("Face recognition is not yet completed.")
|
||||||
|
|
||||||
|
if not self.is_context_success(context):
|
||||||
|
msg = context.get('error_message', '')
|
||||||
|
raise RuntimeError("Face recognition failed,{}".format(msg))
|
||||||
|
|
||||||
face_code = context.get('face_code')
|
face_code = context.get('face_code')
|
||||||
if not face_code:
|
if not face_code:
|
||||||
raise ValueError("Face code is missing from the context.")
|
raise ValueError("Face code is missing from the context.")
|
||||||
|
|
|
@ -58,7 +58,7 @@ class MFAFaceCallbackSerializer(serializers.Serializer):
|
||||||
token = serializers.CharField(required=True, allow_blank=False)
|
token = serializers.CharField(required=True, allow_blank=False)
|
||||||
success = serializers.BooleanField(required=True, allow_null=False)
|
success = serializers.BooleanField(required=True, allow_null=False)
|
||||||
error_message = serializers.CharField(required=False, allow_null=True, allow_blank=True)
|
error_message = serializers.CharField(required=False, allow_null=True, allow_blank=True)
|
||||||
face_code = serializers.CharField(required=True)
|
face_code = serializers.CharField(required=False, allow_null=True, allow_blank=True)
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue