Update misc.go

This commit is contained in:
VMCoud 2023-07-29 20:19:33 +08:00 committed by GitHub
parent 3e81d8af45
commit 3ae8737402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,6 +78,27 @@ func SendEmailVerification(c *gin.Context) {
})
return
}
// 允许的邮箱后缀列表
allowedEmailSuffixes := []string{
"@163.com", "@qq.com", "@126.com", "@139.com", "@sina.com",
"@sohu.com", "@gmail.com", "@189.cn", "@yeah.net", "@foxmail.com",
}
validSuffix := false
for _, suffix := range allowedEmailSuffixes {
if strings.HasSuffix(email, suffix) {
validSuffix = true
break
}
}
if !validSuffix {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": "不支持此邮箱",
})
return
}
if model.IsEmailAlreadyTaken(email) {
c.JSON(http.StatusOK, gin.H{
"success": false,