| @@ -13,6 +13,7 @@ import ( | |||||
| "code.gitea.io/gitea/modules/convert" | "code.gitea.io/gitea/modules/convert" | ||||
| "code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
| "code.gitea.io/gitea/modules/password" | "code.gitea.io/gitea/modules/password" | ||||
| "code.gitea.io/gitea/modules/setting" | |||||
| api "code.gitea.io/gitea/modules/structs" | api "code.gitea.io/gitea/modules/structs" | ||||
| "code.gitea.io/gitea/services/mailer" | "code.gitea.io/gitea/services/mailer" | ||||
| ) | ) | ||||
| @@ -67,7 +68,7 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { | |||||
| Email: form.Email, | Email: form.Email, | ||||
| Passwd: form.Password, | Passwd: form.Password, | ||||
| MustChangePassword: false, | MustChangePassword: false, | ||||
| IsActive: true, | |||||
| IsActive: !setting.Service.RegisterEmailConfirm, | |||||
| LoginType: models.LoginPlain, | LoginType: models.LoginPlain, | ||||
| } | } | ||||
| if form.MustChangePassword != nil { | if form.MustChangePassword != nil { | ||||
| @@ -81,7 +82,7 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { | |||||
| if !password.IsComplexEnough(form.Password) { | if !password.IsComplexEnough(form.Password) { | ||||
| log.Error("CreateUser failed: PasswordComplexity", ctx.Data["MsgID"]) | log.Error("CreateUser failed: PasswordComplexity", ctx.Data["MsgID"]) | ||||
| ctx.JSON(http.StatusBadRequest, map[string]string{ | ctx.JSON(http.StatusBadRequest, map[string]string{ | ||||
| "error_msg": "PasswordComplexity", | |||||
| "error_msg": "PasswordComplexity", | |||||
| }) | }) | ||||
| return | return | ||||
| } | } | ||||
| @@ -91,14 +92,14 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { | |||||
| models.IsErrNameReserved(err) || | models.IsErrNameReserved(err) || | ||||
| models.IsErrNameCharsNotAllowed(err) || | models.IsErrNameCharsNotAllowed(err) || | ||||
| models.IsErrNamePatternNotAllowed(err) { | models.IsErrNamePatternNotAllowed(err) { | ||||
| log.Error("CreateUser failed:%v",err.Error(), ctx.Data["MsgID"]) | |||||
| log.Error("CreateUser failed:%v", err.Error(), ctx.Data["MsgID"]) | |||||
| ctx.JSON(http.StatusUnprocessableEntity, map[string]string{ | ctx.JSON(http.StatusUnprocessableEntity, map[string]string{ | ||||
| "error_msg": err.Error(), | |||||
| "error_msg": err.Error(), | |||||
| }) | }) | ||||
| } else { | } else { | ||||
| log.Error("CreateUser failed:%v",err.Error(), ctx.Data["MsgID"]) | |||||
| log.Error("CreateUser failed:%v", err.Error(), ctx.Data["MsgID"]) | |||||
| ctx.JSON(http.StatusInternalServerError, map[string]string{ | ctx.JSON(http.StatusInternalServerError, map[string]string{ | ||||
| "error_msg": err.Error(), | |||||
| "error_msg": err.Error(), | |||||
| }) | }) | ||||
| } | } | ||||
| return | return | ||||
| @@ -111,6 +112,3 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { | |||||
| } | } | ||||
| ctx.JSON(http.StatusCreated, convert.ToUser(u, ctx.IsSigned, ctx.User.IsAdmin)) | ctx.JSON(http.StatusCreated, convert.ToUser(u, ctx.IsSigned, ctx.User.IsAdmin)) | ||||
| } | } | ||||