@@ -40,6 +40,50 @@ Success response (201 Created):
4040Errors:
4141- 400 Bad Request — validation failure (missing/weak password, invalid email)
4242- 400 Bad Request — email already exists
43+ - 400 Bad Request — registration already pending from this IP
44+
45+ ---
46+
47+ ## Email verification flow
48+
49+ Purpose: verify the email address used during registration.
50+
51+ After a successful ` POST /auth/register ` , the newly created user has ` isVerified: false ` and
52+ cannot log in — login will return ` 401 Unauthorized ` with the message
53+ ` "Please verify your email before logging in." ` .
54+
55+ The user receives an email containing a verification link that points to the
56+ ` POST /auth/verify-email ` endpoint:
57+
58+ ** Request:**
59+ ``` json
60+ { "token" : " 62-char-random-token" }
61+ ```
62+
63+ ** Success response (200 OK):**
64+ ``` json
65+ {
66+ "message" : " Email verified successfully" ,
67+ "user" : { "id" : " user_abc123" , "email" : " user@example.com" , "firstName" : " Jane" },
68+ "accessToken" : " ey..." ,
69+ "refreshToken" : " ey..."
70+ }
71+ ```
72+
73+ Errors:
74+ - 400 Bad Request — invalid or expired verification token
75+ - 400 Bad Request — email already verified
76+
77+ ### Token expiry
78+
79+ The verification token expires after the duration configured in
80+ ` EMAIL_VERIFICATION_EXPIRES_IN ` (default: ` 24h ` ). When the token expires, the user must request
81+ a new verification email via ` POST /api/users/email/resend ` (or re-register).
82+
83+ ### Registration from the same IP
84+
85+ To prevent abuse, a second registration from the same IP is blocked until the pending email
86+ verification is either completed or the token expires. This is a soft, in-memory guard.
4387
4488---
4589
0 commit comments