app端密钥登录validate

This commit is contained in:
caoqianming 2022-10-14 13:41:20 +08:00
parent e0d779d623
commit 3180af943c
1 changed files with 5 additions and 2 deletions

View File

@ -183,8 +183,11 @@ class SecretLogin(CreateAPIView):
serializer_class = SecretLoginSerializer
def post(self, request):
username = request.data['username']
secret = request.data['secret']
sr = SecretLoginSerializer(data=request.data)
sr.is_valid(raise_exception=True)
vdata = sr.validated_data
username = vdata['username']
secret = vdata['secret']
user = User.objects.filter(Q(username=username) | Q(phone=username) | Q(
employee__id_number=username)).filter(secret=secret).first()
if user: