mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-06-27 22:03:58 +00:00
Update OTP generation interval, enhance SMS sending functionality, and add age validation for temporary user registration
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m50s
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m50s
This commit is contained in:
45
api/tasks.py
45
api/tasks.py
@ -1,8 +1,12 @@
|
||||
from django.shortcuts import get_object_or_404
|
||||
from api.models import User
|
||||
from api.sms import send_sms
|
||||
import requests
|
||||
from apibase.env import env, BASE_DIR
|
||||
import os
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
env.read_env(os.path.join(BASE_DIR, ".env"))
|
||||
@ -26,32 +30,57 @@ def verify_user_with_person_api_task(user_id: int):
|
||||
api_name = data.get("name_en")
|
||||
api_house_name = data.get("house_name_en")
|
||||
api_dob = data.get("dob")
|
||||
print(f"API nic: {api_nic}")
|
||||
print(f"API name: {api_name}")
|
||||
print(f"API house name: {api_house_name}")
|
||||
print(f"API dob: {api_dob}")
|
||||
api_atoll = data.get("atoll_en")
|
||||
api_island_name = data.get("island_name_en")
|
||||
|
||||
logger.info(f"API nic: {api_nic}")
|
||||
logger.info(f"API name: {api_name}")
|
||||
logger.info(f"API house name: {api_house_name}")
|
||||
logger.info(f"API dob: {api_dob}")
|
||||
logger.info(f"API atoll: {api_atoll}")
|
||||
logger.info(f"API island name: {api_island_name}")
|
||||
|
||||
user_nic = user.id_card
|
||||
user_name = f"{user.first_name} {user.last_name}"
|
||||
user_house_name = user.address
|
||||
user_dob = user.dob.isoformat()
|
||||
|
||||
print(f"User nic: {user_nic}")
|
||||
print(f"User name: {user_name}")
|
||||
print(f"User house name: {user_house_name}")
|
||||
print(f"User dob: {user_dob}")
|
||||
logger.info(f"User nic: {user_nic}")
|
||||
logger.info(f"User name: {user_name}")
|
||||
logger.info(f"User house name: {user_house_name}")
|
||||
logger.info(f"User dob: {user_dob}")
|
||||
logger.info(f"User atoll: {user.atoll}")
|
||||
logger.info(f"User island name: {user.island}")
|
||||
|
||||
logger.info(f"case User atoll: {user.atoll == api_atoll}")
|
||||
logger.info("api atoll type: ", {type(api_atoll)})
|
||||
logger.info("user atoll type: ", {type(user.atoll.name)})
|
||||
logger.info(f"case User island name: {user.island == api_island_name}")
|
||||
logger.info(f"api island name type: {type(api_island_name)}")
|
||||
logger.info(f"user island name type: {type(user.island.name)}")
|
||||
|
||||
if (
|
||||
data.get("nic") == user.id_card
|
||||
and data.get("name_en") == f"{user.first_name} {user.last_name}"
|
||||
and data.get("house_name_en") == user.address
|
||||
and data.get("dob").split("T")[0] == user.dob.isoformat()
|
||||
and data.get("atoll_en").strip() == user.atoll.name
|
||||
and data.get("island_name_en").strip() == user.island.name
|
||||
):
|
||||
user.verified = True
|
||||
user.save()
|
||||
send_sms(
|
||||
user.mobile,
|
||||
f"Dear {user.first_name} {user.last_name}, \n\nYour account has been successfully and verified. \n\nYou can now manage your devices and make payments through our portal at https://portal.sarlink.net. \n\n - SAR Link",
|
||||
)
|
||||
return True
|
||||
else:
|
||||
user.verified = False
|
||||
user.save()
|
||||
send_sms(
|
||||
user.mobile,
|
||||
f"Dear {user.first_name} {user.last_name}, \n\nYour account registration is being processed. \n\nWe will notify you once verification is complete. \n\n - SAR Link",
|
||||
)
|
||||
return False
|
||||
else:
|
||||
# Handle the error case
|
||||
|
Reference in New Issue
Block a user