|
|
@@ -120,12 +120,17 @@ func SendEmailVerification(c *gin.Context) {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+ parts := strings.Split(email, "@")
|
|
|
+ if len(parts) != 2 {
|
|
|
+ c.JSON(http.StatusOK, gin.H{
|
|
|
+ "success": false,
|
|
|
+ "message": "无效的邮箱地址",
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ localPart := parts[0]
|
|
|
+ domainPart := parts[1]
|
|
|
if common.EmailDomainRestrictionEnabled {
|
|
|
- parts := strings.Split(email, "@")
|
|
|
- localPart := parts[0]
|
|
|
- domainPart := parts[1]
|
|
|
-
|
|
|
- containsSpecialSymbols := strings.Contains(localPart, "+") || strings.Count(localPart, ".") > 1
|
|
|
allowed := false
|
|
|
for _, domain := range common.EmailDomainWhitelist {
|
|
|
if domainPart == domain {
|
|
|
@@ -133,20 +138,25 @@ func SendEmailVerification(c *gin.Context) {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
- if allowed && !containsSpecialSymbols {
|
|
|
+ if !allowed {
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
"success": false,
|
|
|
- "message": "Your email address is allowed.",
|
|
|
+ "message": "The administrator has enabled the email domain name whitelist, and your email address is not allowed due to special symbols or it's not in the whitelist.",
|
|
|
})
|
|
|
return
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if common.EmailAliasRestrictionEnabled {
|
|
|
+ containsSpecialSymbols := strings.Contains(localPart, "+") || strings.Count(localPart, ".") > 1
|
|
|
+ if containsSpecialSymbols {
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
"success": false,
|
|
|
- "message": "The administrator has enabled the email domain name whitelist, and your email address is not allowed due to special symbols or it's not in the whitelist.",
|
|
|
+ "message": "管理员已启用邮箱地址别名限制,您的邮箱地址由于包含特殊符号而被拒绝。",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if model.IsEmailAlreadyTaken(email) {
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
|
"success": false,
|