Spaces:
Sleeping
Sleeping
Refactor OTP handling to continue with email fallback on SMS failure; add timeout parameter to email OTP function and improve SMS client initialization
9e0fc4a Download app/utils/sms_utils.py from bmsadmin/bookmyservice-ums: direct link, hf CLI and curl.
- Browser
- Download file 500 Bytes
-
https://huggingface.co/spaces/bmsadmin/bookmyservice-ums/resolve/main/app/utils/sms_utils.py
- Command line
-
hf download hf://spaces/bmsadmin/bookmyservice-ums/app/utils/sms_utils.py
-
curl -L -o sms_utils.py https://huggingface.co/spaces/bmsadmin/bookmyservice-ums/resolve/main/app/utils/sms_utils.py
500 Bytes
| from twilio.rest import Client | |
| from twilio.http.http_client import TwilioHttpClient | |
| from app.core.config import settings | |
| def send_sms_otp(phone: str, otp: str) -> str: | |
| http_client = TwilioHttpClient(timeout=10) # 10 seconds timeout | |
| client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN, http_client=http_client) | |
| message = client.messages.create( | |
| from_=settings.TWILIO_SMS_FROM, | |
| body=f"Your OTP is {otp}", | |
| to=phone | |
| ) | |
| return message.sid |