check device
This commit is contained in:
parent
558e8b5acd
commit
b4344e3dbd
@ -296,6 +296,7 @@ def get_device_data(request, device_id):
|
||||
|
||||
|
||||
|
||||
|
||||
class CheckDeviceAssociation(APIView):
|
||||
"""
|
||||
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):
|
||||
try:
|
||||
# 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")
|
||||
unique_id = request.data.get("unique_id")
|
||||
|
||||
# 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(
|
||||
{"error": "user_id, mac_address, and unique_id are required."},
|
||||
status=status.HTTP_400_BAD_REQUEST
|
||||
@ -322,7 +323,7 @@ class CheckDeviceAssociation(APIView):
|
||||
|
||||
# Check if the user exists
|
||||
try:
|
||||
user_profile = UserProfile.objects.get(user_id=user_id)
|
||||
user_profile = UserProfile.objects.get(email=email)
|
||||
print(user_profile)
|
||||
except UserProfile.DoesNotExist:
|
||||
# User does not exist
|
||||
|
||||
Loading…
Reference in New Issue
Block a user