]> source.dussan.org Git - gitea.git/commitdiff
Backport: Fix password complexity check on registration (#8887) (#8888)
authorguillep2k <18600385+guillep2k@users.noreply.github.com>
Sat, 9 Nov 2019 11:52:54 +0000 (08:52 -0300)
committerzeripath <art27@cantab.net>
Sat, 9 Nov 2019 11:52:54 +0000 (11:52 +0000)
* Fix registration password complexity

* Fix integration to use a complex password ;)

integrations/signup_test.go
routers/user/auth.go

index 325c906326bf0a1c8f70c497d7a66dd411de8cb6..e122efa39c5b2bd003401c40022efb5f5d84af7d 100644 (file)
@@ -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)
 
index 5d794f78df9a3e022e3a6d7f6027fc5fa44a4839..cb5611e0459ba8e053c6083753c7df60448069d6 100644 (file)
@@ -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,