Skip to content

Commit 6e1912c

Browse files
guillep2klunny
authored andcommitted
Fix password complexity check on registration (#8887)
* Fix registration password complexity * Fix integration to use a complex password ;)
1 parent 9ae4c17 commit 6e1912c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

integrations/signup_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func TestSignup(t *testing.T) {
1919
req := NewRequestWithValues(t, "POST", "/user/sign_up", map[string]string{
2020
"user_name": "exampleUser",
2121
"email": "exampleUser@example.com",
22-
"password": "examplePassword",
23-
"retype": "examplePassword",
22+
"password": "examplePassword!1",
23+
"retype": "examplePassword!1",
2424
})
2525
MakeRequest(t, req, http.StatusFound)
2626

routers/user/auth.go

+5
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,11 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo
10701070
ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplSignUp, &form)
10711071
return
10721072
}
1073+
if !password.IsComplexEnough(form.Password) {
1074+
ctx.Data["Err_Password"] = true
1075+
ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplSignUp, &form)
1076+
return
1077+
}
10731078

10741079
u := &models.User{
10751080
Name: form.UserName,

0 commit comments

Comments
 (0)