基本功能已初步完善
This commit is contained in:
@@ -99,10 +99,6 @@ func Register(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if service.IsPluginEnabled(service.PluginUserAddIPv6) && user.PlanID != nil {
|
||||
service.SyncIPv6ShadowAccount(&user)
|
||||
}
|
||||
|
||||
token, err := utils.GenerateToken(user.ID, user.IsAdmin)
|
||||
if err != nil {
|
||||
Fail(c, http.StatusInternalServerError, "failed to create auth token")
|
||||
@@ -166,7 +162,29 @@ func SendEmailVerify(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
service.StoreEmailVerifyCode(strings.ToLower(strings.TrimSpace(req.Email)), code, 10*time.Minute)
|
||||
email := strings.ToLower(strings.TrimSpace(req.Email))
|
||||
subject := fmt.Sprintf("[%s] Email verification code", service.MustGetString("app_name", "XBoard"))
|
||||
textBody := strings.Join([]string{
|
||||
"Your email verification code is:",
|
||||
code,
|
||||
"",
|
||||
"This code will expire in 10 minutes.",
|
||||
}, "\n")
|
||||
htmlBody := fmt.Sprintf(
|
||||
"<h2>Email verification</h2><p>Your verification code is <strong style=\"font-size:24px;letter-spacing:4px;\">%s</strong>.</p><p>This code will expire in 10 minutes.</p>",
|
||||
code,
|
||||
)
|
||||
if err := service.SendMailWithCurrentSettings(service.EmailMessage{
|
||||
To: []string{email},
|
||||
Subject: subject,
|
||||
TextBody: textBody,
|
||||
HTMLBody: htmlBody,
|
||||
}); err != nil {
|
||||
Fail(c, http.StatusInternalServerError, "failed to send verification email: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
service.StoreEmailVerifyCode(email, code, 10*time.Minute)
|
||||
SuccessMessage(c, "email verify code generated", gin.H{
|
||||
"email": req.Email,
|
||||
"debug_code": code,
|
||||
|
||||
Reference in New Issue
Block a user