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)
| 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. |
| 823 | func (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. |
no test coverage detected