check device

This commit is contained in:
Vratika 2024-12-10 13:41:54 +05:30
parent 558e8b5acd
commit b4344e3dbd

View File

@ -296,6 +296,7 @@ def get_device_data(request, device_id):
class CheckDeviceAssociation(APIView): class CheckDeviceAssociation(APIView):
""" """
API to check if the given device is associated with the user based on API to check if the given device is associated with the user based on
@ -309,12 +310,12 @@ class CheckDeviceAssociation(APIView):
def post(self, request): def post(self, request):
try: try:
# Extract the required parameters from the request body # Extract the required parameters from the request body
user_id = request.data.get("user_id") email = request.data.get("email")
mac_address = request.data.get("mac_address") mac_address = request.data.get("mac_address")
unique_id = request.data.get("unique_id") unique_id = request.data.get("unique_id")
# Validate the presence of required parameters # Validate the presence of required parameters
if not user_id or not mac_address or not unique_id: if not email or not mac_address or not unique_id:
return Response( return Response(
{"error": "user_id, mac_address, and unique_id are required."}, {"error": "user_id, mac_address, and unique_id are required."},
status=status.HTTP_400_BAD_REQUEST status=status.HTTP_400_BAD_REQUEST
@ -322,7 +323,7 @@ class CheckDeviceAssociation(APIView):
# Check if the user exists # Check if the user exists
try: try:
user_profile = UserProfile.objects.get(user_id=user_id) user_profile = UserProfile.objects.get(email=email)
print(user_profile) print(user_profile)
except UserProfile.DoesNotExist: except UserProfile.DoesNotExist:
# User does not exist # User does not exist