From c6984b2020f604aa5cd7375997825d75406a71d2 Mon Sep 17 00:00:00 2001 From: Devon Mizelle Date: Wed, 29 Sep 2021 19:46:08 -0400 Subject: [PATCH] move the call to validatePassword into the switch statement --- clientapi/routing/register.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 42aabd598..eb7333819 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -232,7 +232,7 @@ func validatePassword(password string, cfg config.PasswordRequirements) *util.JS Code: http.StatusBadRequest, JSON: jsonerror.WeakPassword(fmt.Sprintf("'password' >%d characters", cfg.MaxPasswordLength)), } - } else if len(password) >= 0 && len(password) < cfg.MinPasswordLength { + } else if len(password) > 0 && len(password) < cfg.MinPasswordLength { return &util.JSONResponse{ Code: http.StatusBadRequest, JSON: jsonerror.WeakPassword(fmt.Sprintf("password too weak: min %d chars", cfg.MinPasswordLength)), @@ -541,9 +541,9 @@ func Register( if resErr = validateUsername(r.Username); resErr != nil { return *resErr } - } - if resErr = validatePassword(r.Password, cfg.PasswordRequirements); resErr != nil { - return *resErr + if resErr = validatePassword(r.Password, cfg.PasswordRequirements); resErr != nil { + return *resErr + } } logger := util.GetLogger(req.Context())