Skip to content

Commit

Permalink
Backport: Fix password complexity check on registration (#8887) (#8888)
Browse files Browse the repository at this point in the history
* Fix registration password complexity

* Fix integration to use a complex password ;)
  • Loading branch information
guillep2k authored and zeripath committed Nov 9, 2019
1 parent 1275c88 commit fbcf235
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integrations/signup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions routers/user/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fbcf235

Please sign in to comment.