Browse Source

add mail verify

pull/176/head
lewis 3 years ago
parent
commit
428afdf7d0
1 changed files with 7 additions and 9 deletions
  1. +7
    -9
      routers/secure/user.go

+ 7
- 9
routers/secure/user.go View File

@@ -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))
}




Loading…
Cancel
Save