diff options
Diffstat (limited to 'routers/admin/users.go')
-rw-r--r-- | routers/admin/users.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go index 660f116682..fdc4e0e371 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/password" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers" "code.gitea.io/gitea/services/mailer" @@ -94,7 +95,10 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) { u.LoginName = form.LoginName } } - + if !password.IsComplexEnough(form.Password) { + ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form) + return + } if err := models.CreateUser(u); err != nil { switch { case models.IsErrUserAlreadyExist(err): @@ -201,6 +205,10 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) { ctx.ServerError("UpdateUser", err) return } + if !password.IsComplexEnough(form.Password) { + ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserEdit, &form) + return + } u.HashPassword(form.Password) } |