Spaces:
Build error
Build error
File size: 994 Bytes
4438ee0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from fastapi import APIRouter, HTTPException
from app.services.otp_service import generate_otp_service, validate_otp_service
otp_router = APIRouter()
@otp_router.post("/generate-otp")
async def generate_otp(identifier: str):
"""
Generate and send an OTP for a given identifier (email or mobile).
"""
try:
await generate_otp_service(identifier)
return {"message": "OTP generated and sent successfully."}
except HTTPException as e:
raise e
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@otp_router.post("/validate-otp")
async def validate_user_otp(identifier: str, otp: str):
"""
Validate the OTP for a given identifier (email or mobile).
"""
try:
await validate_otp_service(identifier, otp)
return {"message": "OTP validated successfully."}
except HTTPException as e:
raise e
except Exception as e:
raise HTTPException(status_code=500, detail=str(e)) |