Remove demo mode from signup OTP verification flow
Browse files
backend/app/api/auth.py
CHANGED
|
@@ -27,10 +27,9 @@ _otp_store: dict[str, dict] = {}
|
|
| 27 |
def send_otp(payload: dict, db: Session = Depends(get_db)):
|
| 28 |
"""
|
| 29 |
Generate and send an OTP for email verification during signup.
|
| 30 |
-
|
| 31 |
-
If not, returns OTP in response (demo mode).
|
| 32 |
"""
|
| 33 |
-
from app.services.email_service import send_otp_email
|
| 34 |
|
| 35 |
email = payload.get("email", "").strip().lower()
|
| 36 |
username = payload.get("username", "")
|
|
@@ -59,16 +58,10 @@ def send_otp(payload: dict, db: Session = Depends(get_db)):
|
|
| 59 |
"password": password,
|
| 60 |
}
|
| 61 |
|
| 62 |
-
#
|
| 63 |
-
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
# Only show OTP preview if email sending is not configured (demo mode)
|
| 68 |
-
if not email_sent:
|
| 69 |
-
response["otp_preview"] = otp_code
|
| 70 |
-
|
| 71 |
-
return response
|
| 72 |
|
| 73 |
|
| 74 |
@router.post("/verify-otp")
|
|
|
|
| 27 |
def send_otp(payload: dict, db: Session = Depends(get_db)):
|
| 28 |
"""
|
| 29 |
Generate and send an OTP for email verification during signup.
|
| 30 |
+
Sends a 6-digit code to the provided email address.
|
|
|
|
| 31 |
"""
|
| 32 |
+
from app.services.email_service import send_otp_email
|
| 33 |
|
| 34 |
email = payload.get("email", "").strip().lower()
|
| 35 |
username = payload.get("username", "")
|
|
|
|
| 58 |
"password": password,
|
| 59 |
}
|
| 60 |
|
| 61 |
+
# Send verification email
|
| 62 |
+
send_otp_email(email, otp_code)
|
| 63 |
|
| 64 |
+
return {"message": f"Verification code sent to {email}"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
@router.post("/verify-otp")
|
backend/app/services/email_service.py
CHANGED
|
@@ -3,8 +3,6 @@ Email service for sending OTP verification codes and password reset links.
|
|
| 3 |
|
| 4 |
Uses Resend HTTP API (works from any environment, no SMTP port restrictions).
|
| 5 |
Configure via environment variable: RESEND_API_KEY
|
| 6 |
-
|
| 7 |
-
Falls back to demo mode (returns OTP on screen) if not configured.
|
| 8 |
"""
|
| 9 |
|
| 10 |
import os
|
|
|
|
| 3 |
|
| 4 |
Uses Resend HTTP API (works from any environment, no SMTP port restrictions).
|
| 5 |
Configure via environment variable: RESEND_API_KEY
|
|
|
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
import os
|
frontend/src/components/auth/AuthLayout.css
CHANGED
|
@@ -237,15 +237,6 @@
|
|
| 237 |
border-radius: var(--radius-sm);
|
| 238 |
}
|
| 239 |
|
| 240 |
-
.dw-auth-form__otp-preview {
|
| 241 |
-
font-size: var(--text-sm);
|
| 242 |
-
color: var(--color-accent-text);
|
| 243 |
-
background: var(--color-accent-soft);
|
| 244 |
-
padding: var(--space-2) var(--space-3);
|
| 245 |
-
border-radius: var(--radius-sm);
|
| 246 |
-
text-align: center;
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
.dw-auth-form__resend {
|
| 250 |
background: none;
|
| 251 |
border: none;
|
|
|
|
| 237 |
border-radius: var(--radius-sm);
|
| 238 |
}
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
.dw-auth-form__resend {
|
| 241 |
background: none;
|
| 242 |
border: none;
|
frontend/src/pages/auth/Signup.jsx
CHANGED
|
@@ -28,7 +28,6 @@ export default function Signup() {
|
|
| 28 |
const [confirmPassword, setConfirmPassword] = useState("");
|
| 29 |
const [showPassword, setShowPassword] = useState(false);
|
| 30 |
const [otpCode, setOtpCode] = useState("");
|
| 31 |
-
const [otpPreview, setOtpPreview] = useState("");
|
| 32 |
const [error, setError] = useState(null);
|
| 33 |
const [loading, setLoading] = useState(false);
|
| 34 |
|
|
@@ -57,10 +56,6 @@ export default function Signup() {
|
|
| 57 |
return;
|
| 58 |
}
|
| 59 |
|
| 60 |
-
// In demo mode, OTP is returned in response
|
| 61 |
-
if (result?.otp_preview) {
|
| 62 |
-
setOtpPreview(result.otp_preview);
|
| 63 |
-
}
|
| 64 |
setStep("otp");
|
| 65 |
} catch {
|
| 66 |
setError("Couldn't reach the server. Please try again.");
|
|
@@ -117,11 +112,6 @@ export default function Signup() {
|
|
| 117 |
}
|
| 118 |
>
|
| 119 |
<form onSubmit={handleVerifyOtp} className="dw-auth-form">
|
| 120 |
-
{otpPreview && (
|
| 121 |
-
<div className="dw-auth-form__otp-preview">
|
| 122 |
-
Demo mode — your code is: <strong>{otpPreview}</strong>
|
| 123 |
-
</div>
|
| 124 |
-
)}
|
| 125 |
<Input
|
| 126 |
label="Verification code"
|
| 127 |
type="text"
|
|
|
|
| 28 |
const [confirmPassword, setConfirmPassword] = useState("");
|
| 29 |
const [showPassword, setShowPassword] = useState(false);
|
| 30 |
const [otpCode, setOtpCode] = useState("");
|
|
|
|
| 31 |
const [error, setError] = useState(null);
|
| 32 |
const [loading, setLoading] = useState(false);
|
| 33 |
|
|
|
|
| 56 |
return;
|
| 57 |
}
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
setStep("otp");
|
| 60 |
} catch {
|
| 61 |
setError("Couldn't reach the server. Please try again.");
|
|
|
|
| 112 |
}
|
| 113 |
>
|
| 114 |
<form onSubmit={handleVerifyOtp} className="dw-auth-form">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
<Input
|
| 116 |
label="Verification code"
|
| 117 |
type="text"
|