From d807299776e28e15340c8c5abecc055f28838c13 Mon Sep 17 00:00:00 2001 From: ckt1031 <65409152+ckt1031@users.noreply.github.com> Date: Sun, 30 Jul 2023 11:54:58 +0800 Subject: [PATCH] fix: disable email sending while registration was locked --- controller/misc.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/controller/misc.go b/controller/misc.go index 958a3716..210731de 100644 --- a/controller/misc.go +++ b/controller/misc.go @@ -3,10 +3,11 @@ package controller import ( "encoding/json" "fmt" - "github.com/gin-gonic/gin" "net/http" "one-api/common" "one-api/model" + + "github.com/gin-gonic/gin" ) func GetStatus(c *gin.Context) { @@ -85,6 +86,13 @@ func SendEmailVerification(c *gin.Context) { }) return } + if !common.RegisterEnabled { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "管理员关闭了新用户注册", + }) + return + } code := common.GenerateVerificationCode(6) common.RegisterVerificationCodeWithKey(email, code, common.EmailVerificationPurpose) subject := fmt.Sprintf("%s邮箱验证邮件", common.SystemName)