diff --git a/routers/secure/user.go b/routers/secure/user.go index e9017cfd4..8c06b0dab 100755 --- a/routers/secure/user.go +++ b/routers/secure/user.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/convert" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/password" + "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/services/mailer" ) @@ -67,7 +68,7 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { Email: form.Email, Passwd: form.Password, MustChangePassword: false, - IsActive: true, + IsActive: !setting.Service.RegisterEmailConfirm, LoginType: models.LoginPlain, } if form.MustChangePassword != nil { @@ -81,7 +82,7 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { if !password.IsComplexEnough(form.Password) { log.Error("CreateUser failed: PasswordComplexity", ctx.Data["MsgID"]) ctx.JSON(http.StatusBadRequest, map[string]string{ - "error_msg": "PasswordComplexity", + "error_msg": "PasswordComplexity", }) return } @@ -91,14 +92,14 @@ func CreateUser(ctx *context.Context, form api.CreateUserOption) { models.IsErrNameReserved(err) || models.IsErrNameCharsNotAllowed(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{ - "error_msg": err.Error(), + "error_msg": err.Error(), }) } 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{ - "error_msg": err.Error(), + "error_msg": err.Error(), }) } 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)) } - - -