feat: add email verify code endpoint and require code on register
- POST /v1/user/email/code sends a 6-digit verify code via email (rate-limited, 10min TTL) - RegisterByEmail now validates verify_code before creating the account - Added email code cache helpers mirroring SMS pattern - Added error codes 1007 (email code error) and 1008 (send limit) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,8 @@ const (
|
||||
CodeEmailExists = 1004
|
||||
CodeEmailNotFound = 1005
|
||||
CodePasswordMismatch = 1006
|
||||
CodeEmailCodeError = 1007
|
||||
CodeEmailSendLimit = 1008
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -36,6 +38,8 @@ const (
|
||||
CodeEmailExistsMsg = "email already registered"
|
||||
CodeEmailNotFoundMsg = "email not found"
|
||||
CodePasswordMismatchMsg = "password mismatch"
|
||||
CodeEmailCodeErrorMsg = "email verify code error"
|
||||
CodeEmailSendLimitMsg = "email send limit reached"
|
||||
)
|
||||
|
||||
type BusinessError struct {
|
||||
@@ -61,4 +65,6 @@ var (
|
||||
ErrEmailExists = NewError(CodeEmailExists, CodeEmailExistsMsg, nil)
|
||||
ErrEmailNotFound = NewError(CodeEmailNotFound, CodeEmailNotFoundMsg, nil)
|
||||
ErrPasswordMismatch = NewError(CodePasswordMismatch, CodePasswordMismatchMsg, nil)
|
||||
ErrEmailCodeError = NewError(CodeEmailCodeError, CodeEmailCodeErrorMsg, nil)
|
||||
ErrEmailSendLimit = NewError(CodeEmailSendLimit, CodeEmailSendLimitMsg, nil)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user