summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorguillep2k <18600385+guillep2k@users.noreply.github.com>2019-11-19 19:44:58 -0300
committerzeripath <art27@cantab.net>2019-11-19 22:44:58 +0000
commitc57edb6c7b5066da2b0f526e6ab9f7842fd785fb (patch)
tree68d44a4dbc58f8ade1373eb30fe850410511ce43 /routers
parenteb0359cad4b725553c8bca3e95ada9c789c5da0b (diff)
downloadgitea-c57edb6c7b5066da2b0f526e6ab9f7842fd785fb.tar.gz
gitea-c57edb6c7b5066da2b0f526e6ab9f7842fd785fb.zip
Add password requirement info on error (#9074)
* Add password requirement info on error * Move BuildComplexityError to the password pkg * Unexport complexity type * Fix extra line * Update modules/password/password.go Co-Authored-By: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers')
-rw-r--r--routers/admin/users.go4
-rw-r--r--routers/user/auth.go4
-rw-r--r--routers/user/setting/account.go2
-rw-r--r--routers/user/setting/account_test.go2
4 files changed, 6 insertions, 6 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 2284f21838..7626fbc0d0 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -96,7 +96,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
}
if u.LoginType == models.LoginPlain {
if !password.IsComplexEnough(form.Password) {
- ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
+ ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserNew, &form)
return
}
u.MustChangePassword = form.MustChangePassword
@@ -208,7 +208,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
return
}
if !password.IsComplexEnough(form.Password) {
- ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserEdit, &form)
+ ctx.RenderWithErr(password.BuildComplexityError(ctx), tplUserEdit, &form)
return
}
u.HashPassword(form.Password)
diff --git a/routers/user/auth.go b/routers/user/auth.go
index cb5611e045..d0ad4afffd 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -1072,7 +1072,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo
}
if !password.IsComplexEnough(form.Password) {
ctx.Data["Err_Password"] = true
- ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplSignUp, &form)
+ ctx.RenderWithErr(password.BuildComplexityError(ctx), tplSignUp, &form)
return
}
@@ -1343,7 +1343,7 @@ func ResetPasswdPost(ctx *context.Context) {
} else if !password.IsComplexEnough(passwd) {
ctx.Data["IsResetForm"] = true
ctx.Data["Err_Password"] = true
- ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplResetPassword, nil)
+ ctx.RenderWithErr(password.BuildComplexityError(ctx), tplResetPassword, nil)
return
}
diff --git a/routers/user/setting/account.go b/routers/user/setting/account.go
index 73799c8bd7..a9064b0e15 100644
--- a/routers/user/setting/account.go
+++ b/routers/user/setting/account.go
@@ -53,7 +53,7 @@ func AccountPost(ctx *context.Context, form auth.ChangePasswordForm) {
} else if form.Password != form.Retype {
ctx.Flash.Error(ctx.Tr("form.password_not_match"))
} else if !password.IsComplexEnough(form.Password) {
- ctx.Flash.Error(ctx.Tr("form.password_complexity"))
+ ctx.Flash.Error(password.BuildComplexityError(ctx))
} else {
var err error
if ctx.User.Salt, err = models.GetUserSalt(); err != nil {
diff --git a/routers/user/setting/account_test.go b/routers/user/setting/account_test.go
index 41783e19d7..841ecb8ac2 100644
--- a/routers/user/setting/account_test.go
+++ b/routers/user/setting/account_test.go
@@ -91,7 +91,7 @@ func TestChangePassword(t *testing.T) {
Retype: req.Retype,
})
- assert.EqualValues(t, req.Message, ctx.Flash.ErrorMsg)
+ assert.Contains(t, ctx.Flash.ErrorMsg, req.Message)
assert.EqualValues(t, http.StatusFound, ctx.Resp.Status())
}
}