Skip to content

Commit

Permalink
Refactor error handling in checkBruteForcePrevention
Browse files Browse the repository at this point in the history
Move RedisReadCounter increment outside the error check clause to ensure it is always executed. Simplify the return statement for clarity and brevity.

Signed-off-by: Christian Roessner <c@roessner.co>
  • Loading branch information
Christian Roessner committed Oct 30, 2024
1 parent 61841b3 commit 27a9c46
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions server/core/bruteforce.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,11 @@ func (a *AuthState) userExists() (bool, error) {
accountName, err := backend.LookupUserAccountFromRedis(a.HTTPClientContext, a.Username)
if err != nil {
return false, err
} else {
stats.RedisReadCounter.Inc()
}

if accountName == "" {
return false, nil
}
stats.RedisReadCounter.Inc()

return true, nil
return accountName != "", nil
}

// checkEnforceBruteForceComputation checks the enforcement rules for brute force computation.
Expand Down

0 comments on commit 27a9c46

Please sign in to comment.