diff options
author | guillep2k <18600385+guillep2k@users.noreply.github.com> | 2019-11-09 08:52:54 -0300 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-11-09 11:52:54 +0000 |
commit | fbcf2356334d5b052f9df2468690fe7530605520 (patch) | |
tree | 16ea0ab1e70e170b10a0edd04f059ffb38e85d30 | |
parent | 1275c88589b04319631755eb4359864de8ae5130 (diff) | |
download | gitea-fbcf2356334d5b052f9df2468690fe7530605520.tar.gz gitea-fbcf2356334d5b052f9df2468690fe7530605520.zip |
Backport: Fix password complexity check on registration (#8887) (#8888)
* Fix registration password complexity
* Fix integration to use a complex password ;)
-rw-r--r-- | integrations/signup_test.go | 4 | ||||
-rw-r--r-- | routers/user/auth.go | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/integrations/signup_test.go b/integrations/signup_test.go index 325c906326..e122efa39c 100644 --- a/integrations/signup_test.go +++ b/integrations/signup_test.go @@ -19,8 +19,8 @@ func TestSignup(t *testing.T) { req := NewRequestWithValues(t, "POST", "/user/sign_up", map[string]string{ "user_name": "exampleUser", "email": "exampleUser@example.com", - "password": "examplePassword", - "retype": "examplePassword", + "password": "examplePassword!1", + "retype": "examplePassword!1", }) MakeRequest(t, req, http.StatusFound) diff --git a/routers/user/auth.go b/routers/user/auth.go index 5d794f78df..cb5611e045 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -1070,6 +1070,11 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplSignUp, &form) return } + if !password.IsComplexEnough(form.Password) { + ctx.Data["Err_Password"] = true + ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplSignUp, &form) + return + } u := &models.User{ Name: form.UserName, |