fix temporary user id passing to user verification 🐛
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m52s

This commit is contained in:
2025-09-14 21:51:31 +05:00
parent 9721585f8a
commit bfc3fd1b89
2 changed files with 7 additions and 3 deletions

View File

@@ -42,7 +42,8 @@ def assign_device_permissions(sender, instance, created, **kwargs):
@receiver(post_save, sender=TemporaryUser) @receiver(post_save, sender=TemporaryUser)
def verify_user_with_person_api(sender, instance, created, **kwargs): def verify_user_with_person_api(sender, instance, created, **kwargs):
if created: if created:
verify_user_with_person_api_task(instance.id) print(f"Temporary User Instance: {instance}")
verify_user_with_person_api_task(instance.t_id)
@receiver(reset_password_token_created) @receiver(reset_password_token_created)

View File

@@ -143,13 +143,16 @@ def verify_user_with_person_api_task(user_id: int):
Verify the user with the Person API. Verify the user with the Person API.
:param user_id: The ID of the user to verify. :param user_id: The ID of the user to verify.
""" """
print(f"Verifying user with ID: {user_id}")
if not user_id: if not user_id:
logger.error("User ID is not provided.") logger.error("User ID is not provided.")
return None return None
t_user = get_object_or_404(TemporaryUser, id=user_id) t_user = get_object_or_404(TemporaryUser, t_id=user_id)
if not t_user: if not t_user:
logger.error(f"User with ID {user_id} not found.") logger.error(f"User with ID {user_id} not found.")
return None return None
print(t_user)
return
verification_failed_message = f"""*The following user verification failed*:\n\n*ID Card:* {t_user.t_id_card}\n*Name:* {t_user.t_first_name} {t_user.t_last_name}\n*House Name:* {t_user.t_address}\n*Date of Birth:* {t_user.t_dob}\n*Island:* {(t_user.t_atoll.name if t_user.t_atoll else "N/A")} {(t_user.t_island.name if t_user.t_island else "N/A")}\n*Mobile:* {t_user.t_mobile}\nVisit [SAR Link Portal](https://portal.sarlink.net/users/{user_id}/details) to manually verify this user. verification_failed_message = f"""*The following user verification failed*:\n\n*ID Card:* {t_user.t_id_card}\n*Name:* {t_user.t_first_name} {t_user.t_last_name}\n*House Name:* {t_user.t_address}\n*Date of Birth:* {t_user.t_dob}\n*Island:* {(t_user.t_atoll.name if t_user.t_atoll else "N/A")} {(t_user.t_island.name if t_user.t_island else "N/A")}\n*Mobile:* {t_user.t_mobile}\nVisit [SAR Link Portal](https://portal.sarlink.net/users/{user_id}/details) to manually verify this user.
""" """
@@ -163,7 +166,7 @@ def verify_user_with_person_api_task(user_id: int):
) )
import requests import requests
response = requests.get(f"{PERSON_VERIFY_BASE_URL}/api/person/{t_user.id_card}") response = requests.get(f"{PERSON_VERIFY_BASE_URL}/api/person/{t_user.t_id_card}")
if response.status_code == 200: if response.status_code == 200:
data = response.json() data = response.json()
api_nic = data.get("nic") api_nic = data.get("nic")