This commit is contained in:
Louis Mazin 2026-09-15 20:05:57 +02:00
parent a2fd47369d
commit 4b40d179b8

View File

@ -37,10 +37,12 @@ class TimeEntryScanView(APIView):
permission_classes = [IsAuthenticated]
def post(self, request):
code = request.data.get('code')
if code == config('SECRET_POINTAGE_ENTER', default=''):
code = str(request.data.get('code') or '').strip()
enter_code = config('SECRET_POINTAGE_ENTER', default='').strip()
exit_code = config('SECRET_POINTAGE_EXIT', default='').strip()
if code == enter_code:
action = 'enter'
elif code == config('SECRET_POINTAGE_EXIT', default=''):
elif code == exit_code:
action = 'exit'
else:
return Response({'error': 'QR code de pointage invalide.'}, status=status.HTTP_400_BAD_REQUEST)