Fix AttributeError in Django Allauth Ratelimit Module due to Incorrect Usage of strip() Function #3699
Vaibhav6200
started this conversation in
General
Replies: 1 comment
-
The https://docs.allauth.org/en/latest/account/rate_limits.html As you can see, it is a dictionary mapping a string (e.g.
Why? What is wrong with using the supported syntax? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When attempting to limit the rate of continuous failed login attempts in a Django project using Django Allauth, the settings configuration specifies the number of login attempts allowed (LIMIT) and the block duration in seconds (TIMEOUT). However, upon setting this configuration, an error is encountered when users attempt to initiate a "forgot password" process.
ACCOUNT_RATE_LIMITS = {
'login_failed': {
'LIMIT': 10,
'TIMEOUT': 3600,
},
}
The error arises from "allauth > core > ratelimit.py" in the _parse_rates function (located in line 45), where it attempts to apply the strip() function to a dictionary object. Since dictionaries do not possess a strip() method, this results in an AttributeError.
To resolve this issue, the _parse_rates function in ratelimit.py needs to be updated to handle dictionary objects appropriately. The function should iterate over the dictionary values without attempting to use string methods like strip().
Here is the function which i am talking about:
def _parse_rates(rates):
ret = []
if rates:
rates = rates.strip()
if rates:
parts = rates.split(",")
for part in parts:
ret.append(_parse_rate(part.strip()))
return ret
Beta Was this translation helpful? Give feedback.
All reactions