Spaces:
Runtime error
Runtime error
Update server.py
Browse files
server.py
CHANGED
|
@@ -44,6 +44,19 @@ async def signup(data: AuthData):
|
|
| 44 |
success, msg = auth.signup(data.username, data.password, data.email)
|
| 45 |
return {"success": success, "message": msg}
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
@app.post("/save-session")
|
| 49 |
async def save_session(data: SessionData):
|
|
|
|
| 44 |
success, msg = auth.signup(data.username, data.password, data.email)
|
| 45 |
return {"success": success, "message": msg}
|
| 46 |
|
| 47 |
+
@app.post("/send-otp")
|
| 48 |
+
async def send_otp(data: AuthData):
|
| 49 |
+
# 1. Generate a random 6-digit code
|
| 50 |
+
otp_code = str(random.randint(100000, 999999))
|
| 51 |
+
|
| 52 |
+
# 2. Store it temporarily (or in your DB)
|
| 53 |
+
# 3. Send it via Brevo
|
| 54 |
+
success = auth.send_otp_via_brevo(data.email, otp_code)
|
| 55 |
+
|
| 56 |
+
if success:
|
| 57 |
+
return {"success": True, "message": "OTP Dispatched to Hangar"}
|
| 58 |
+
else:
|
| 59 |
+
return {"success": False, "message": "Signal Interrupted (Brevo Error)"}
|
| 60 |
|
| 61 |
@app.post("/save-session")
|
| 62 |
async def save_session(data: SessionData):
|