Spaces:
Build error
Build error
| from fastapi import APIRouter, HTTPException | |
| from app.services.otp_service import generate_otp_service, validate_otp_service | |
| otp_router = APIRouter() | |
| 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)) | |
| 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)) |