Browse Source

Backport: Fix password complexity check on registration (#8887) (#8888)

* Fix registration password complexity

* Fix integration to use a complex password ;)
release/v1.10
guillep2k 3 years ago
committed by zeripath
parent
commit
fbcf235633
  1. 4
      integrations/signup_test.go
  2. 5
      routers/user/auth.go

4
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)

5
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,

Loading…
Cancel
Save