Skip to content

Commit

Permalink
Add rate limiting exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
skion committed Nov 15, 2023
1 parent 44b7568 commit 190b7c8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions firebase_admin/_auth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,20 @@ def __init__(self, message, cause=None, http_response=None):
exceptions.InvalidArgumentError.__init__(self, message, cause, http_response)


class TooManyAttemptsTryLaterError(exceptions.ResourceExhaustedError):
"""Rate limited because of too many attempts."""

def __init__(self, message, cause=None, http_response=None):
exceptions.ResourceExhaustedError.__init__(self, message, cause, http_response)


class ResetPasswordExceedLimitError(exceptions.ResourceExhaustedError):
"""Reset password emails exceeded their limits."""

def __init__(self, message, cause=None, http_response=None):
exceptions.ResourceExhaustedError.__init__(self, message, cause, http_response)


_CODE_TO_EXC_TYPE = {
'CONFIGURATION_NOT_FOUND': ConfigurationNotFoundError,
'DUPLICATE_EMAIL': EmailAlreadyExistsError,
Expand All @@ -417,6 +431,8 @@ def __init__(self, message, cause=None, http_response=None):
'PHONE_NUMBER_EXISTS': PhoneNumberAlreadyExistsError,
'TENANT_NOT_FOUND': TenantNotFoundError,
'USER_NOT_FOUND': UserNotFoundError,
'TOO_MANY_ATTEMPTS_TRY_LATER': TooManyAttemptsTryLaterError,
'RESET_PASSWORD_EXCEED_LIMIT': ResetPasswordExceedLimitError,
}


Expand Down

0 comments on commit 190b7c8

Please sign in to comment.