]> source.dussan.org Git - gitea.git/commitdiff
Fix password complexity check on registration (#8887)
authorguillep2k <18600385+guillep2k@users.noreply.github.com>
Sat, 9 Nov 2019 03:40:37 +0000 (00:40 -0300)
committerLunny Xiao <xiaolunwen@gmail.com>
Sat, 9 Nov 2019 03:40:37 +0000 (11:40 +0800)
* 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 82a508e4dc84fe0757137069a68beefa8f41de3e..b328ac094efabda0e362ec7f885e5113e9a3f5b6 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,