MCPcopy Create free account
hub / github.com/bytebase/bytebase / checkPasswordLockout

Method checkPasswordLockout

backend/api/v1/auth_service.go:823–834  ·  view source on GitHub ↗

checkPasswordLockout checks if the user has exceeded the password failure rate limit. Returns an error if the user is locked out due to too many failed password attempts.

(ctx context.Context, email string)

Source from the content-addressed store, hash-verified

821// checkPasswordLockout checks if the user has exceeded the password failure rate limit.
822// Returns an error if the user is locked out due to too many failed password attempts.
823func (s *AuthService) checkPasswordLockout(ctx context.Context, email string) error {
824 count, err := s.countRecentLoginFailures(ctx, email, passwordLockoutWindow, errMsgInvalidCredentials)
825 if err != nil {
826 return connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to count recent password failures"))
827 }
828
829 if count >= passwordMaxFailedAttempts {
830 return connect.NewError(connect.CodeResourceExhausted, errors.Errorf(errMsgTooManyPassword))
831 }
832
833 return nil
834}
835
836// checkMFALockout checks if the user has exceeded the MFA failure rate limit.
837// Returns an error if the user is locked out due to too many failed MFA attempts.

Callers 1

getAndVerifyUserMethod · 0.95

Calls 2

ErrorfMethod · 0.80

Tested by

no test coverage detected