From aad9d664cd33a6d6eede0fe04f79972cc15b4c92 Mon Sep 17 00:00:00 2001 From: khushal Date: Mon, 7 Apr 2025 16:26:12 +0530 Subject: [PATCH] Added the mechanism to differentiate between signup and reset requests. --- api/blueprints/common/otp/timed_otp.py | 71 ++++++++++++++++++-------- models/api/common/otp/timed_otp.py | 15 ++++++ to_git.sh | 2 +- 3 files changed, 65 insertions(+), 23 deletions(-) diff --git a/api/blueprints/common/otp/timed_otp.py b/api/blueprints/common/otp/timed_otp.py index f1c6eaf..91e40e4 100644 --- a/api/blueprints/common/otp/timed_otp.py +++ b/api/blueprints/common/otp/timed_otp.py @@ -359,29 +359,56 @@ async def verify_otp( if phone_no.startswith("254"): phone_no = phone_no[3:] if phone_no.startswith("0"): phone_no = phone_no[1:] phone_no = "+254" + phone_no - - # hit Omkar's API: - api_response = await current_app.http_client.post( - url = "https://api.thecaoffice.com/client/add/with/notes", - headers = {"X-Session-Token": inbound_headers["X-Session-Token"]}, - json = { - "email": inbound_data.email, - "clientName": inbound_data.username, - "password": inbound_data.password, - "address": None, - "phoneNo": phone_no, - "city": None, - "pincode": None, - "panCard": None, - "gst": None, - "entity": None, - "country": None, - "startDate": None, - "period": None, - "amount": None - } - ) + # Do this when the user is trying a new sign-up: + # Hit Omkar's API: + if inbound_data.isSignup: + api_response = await current_app.http_client.post( + url = "https://api.thecaoffice.com/client/add/with/notes", + headers = {"X-Session-Token": inbound_headers["X-Session-Token"]}, + json = { + "email": inbound_data.email, + "clientName": inbound_data.username, + "password": inbound_data.password, + "address": None, + "phoneNo": phone_no, + "city": None, + "pincode": None, + "panCard": None, + "gst": None, + "entity": None, + "country": None, + "startDate": None, + "period": None, + "amount": None + } + ) + + # When this is not a new sign-up. it is a password reset request: + # Hit Omkar's API: + else: + api_response = await current_app.http_client.post( + url = "https://api.thecaoffice.com/client/update/with/notes", + headers = {"X-Session-Token": inbound_headers["X-Session-Token"]}, + json = { + "idClient": inbound_data.idClient, + "email": inbound_data.email, + "clientName": inbound_data.clientName, + "username": inbound_data.username, + "password": inbound_data.password, + "address": inbound_data.address, + "phoneNo": phone_no, + "city": inbound_data.city, + "pincode": inbound_data.pincode, + "panCard": inbound_data.panCard, + "gst": inbound_data.gst, + "entity": inbound_data.entity, + "country": inbound_data.country, + "startDate": inbound_data.startDate, + "period": inbound_data.period, + "amount": inbound_data.amount + } + ) # ┳┓ # ┣┫┏┓┏┏┓┏┓┏┓┏┏┓ diff --git a/models/api/common/otp/timed_otp.py b/models/api/common/otp/timed_otp.py index 9a8885f..3a26761 100644 --- a/models/api/common/otp/timed_otp.py +++ b/models/api/common/otp/timed_otp.py @@ -189,11 +189,26 @@ class VerifyTimedOTPRequestData(BaseModel): id: str | Dict | List otp: str + isSignup: bool + username: str password: str email: EmailStr phoneNo: str + idClient: int | None = Field(default = None) + clientName: str | None = Field(default = None) + address: str | None = Field(default = None) + city: str | None = Field(default = None) + pincode: str | None = Field(default = None) + country: str | None = Field(default = None) + panCard: str | None = Field(default = None) + gst: str | None = Field(default = None) + entity: str | None = Field(default = None) + startDate: str | None = Field(default = None) + period: str | None = Field(default = None) + amount: float | int | None = Field(default = None) + class Config: extra = "forbid" diff --git a/to_git.sh b/to_git.sh index 5c57f26..a28ea7c 100644 --- a/to_git.sh +++ b/to_git.sh @@ -18,7 +18,7 @@ echo "Files added." # Make the commit: git commit -m "$COMMENT" -echo "Commit done." +echo "Commit done."get # Push th commit to git: git push -u https://wtt.ditscentre.in/ditscentre/api_utils_converse_v2.git "$BRANCH"