From 8b2aec4ad44b1bc20f638207911b60524209f82f Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 14 Oct 2021 15:17:36 +0800 Subject: [PATCH] fix-429 --- routers/secure/user.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/routers/secure/user.go b/routers/secure/user.go index 8567dc9e6..d5b303d5e 100755 --- a/routers/secure/user.go +++ b/routers/secure/user.go @@ -7,6 +7,7 @@ package secure import ( "net/http" + "net/mail" "strings" "code.gitea.io/gitea/models" @@ -63,6 +64,14 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { // "422": // "$ref": "#/responses/validationError" + _, err1 := mail.ParseAddress(form.Email) + if err1 != nil { + ctx.JSON(http.StatusBadRequest, map[string]string{ + "error_msg": "Email format is wrong.", + }) + return + } + u := &models.User{ Name: form.Username, FullName: form.FullName,