From 3ae873740271e4795f77e0abb3c7bdfee3ed6132 Mon Sep 17 00:00:00 2001 From: VMCoud <59264435+VMCoud@users.noreply.github.com> Date: Sat, 29 Jul 2023 20:19:33 +0800 Subject: [PATCH] Update misc.go --- controller/misc.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/controller/misc.go b/controller/misc.go index 958a3716..7a655b66 100644 --- a/controller/misc.go +++ b/controller/misc.go @@ -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,