diff options
author | Maxim Tkachenko <maxim.tkachenko@gmail.com> | 2019-10-14 22:24:26 +0700 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-10-14 16:24:26 +0100 |
commit | db657192d0349f7b10a62515fbf085d3a48d88f9 (patch) | |
tree | d298b9b2c487af61dc399774e67dcb3440add9c2 /routers/user/auth.go | |
parent | f9aba9ba0f07b77cb46dde6eda3c3f5b8fa841fe (diff) | |
download | gitea-db657192d0349f7b10a62515fbf085d3a48d88f9.tar.gz gitea-db657192d0349f7b10a62515fbf085d3a48d88f9.zip |
Password Complexity Checks (#6230)
Add password complexity checks. The default settings require a lowercase, uppercase, number and a special character within passwords.
Co-Authored-By: T-M-A <maxim.tkachenko@gmail.com>
Co-Authored-By: Lanre Adelowo <adelowomailbox@gmail.com>
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-Authored-By: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/user/auth.go')
-rw-r--r-- | routers/user/auth.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go index 212d535a06..82a508e4dc 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -17,6 +17,7 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/password" "code.gitea.io/gitea/modules/recaptcha" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" @@ -1334,6 +1335,11 @@ func ResetPasswdPost(ctx *context.Context) { ctx.Data["Err_Password"] = true ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplResetPassword, nil) return + } else if !password.IsComplexEnough(passwd) { + ctx.Data["IsResetForm"] = true + ctx.Data["Err_Password"] = true + ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplResetPassword, nil) + return } var err error @@ -1364,7 +1370,6 @@ func ResetPasswdPost(ctx *context.Context) { func MustChangePassword(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("auth.must_change_password") ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/settings/change_password" - ctx.HTML(200, tplMustChangePassword) } @@ -1372,16 +1377,12 @@ func MustChangePassword(ctx *context.Context) { // account was created by an admin func MustChangePasswordPost(ctx *context.Context, cpt *captcha.Captcha, form auth.MustChangePasswordForm) { ctx.Data["Title"] = ctx.Tr("auth.must_change_password") - ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/settings/change_password" - if ctx.HasError() { ctx.HTML(200, tplMustChangePassword) return } - u := ctx.User - // Make sure only requests for users who are eligible to change their password via // this method passes through if !u.MustChangePassword { |