Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias function for is_ratelimited #308

Open
TreyWW opened this issue Oct 30, 2023 · 2 comments
Open

Alias function for is_ratelimited #308

TreyWW opened this issue Oct 30, 2023 · 2 comments

Comments

@TreyWW
Copy link

TreyWW commented Oct 30, 2023

Hey,

Is_ratelimited is a great function, but the name is quite missleading for incrementing. You'd expect it only to be a boolean, but yet it can also increment.
That's great, but I feel we should have also a new function like increment_ratelimit or some sort of increment function which is just a function rather than decorator, that allows you to increment whenever.

At the moment I want to only increment the ratelimit when the user does an unsuccessful login attempt. So i have

is_ratelimited(
                request, group="login_incorrect", key="ip", rate="5/5m", increment=True
)

But instead of that, i'd quite like something like:

increment_ratelimit(request, group="login_incorrect")

Instead i've created my own function that just does the same thing, but it'd be nice to see this in the official version.

Or I may have just missed it 🤷‍♂️

Happy to hear opinions, let me know if i'm just being blind :)

@jsocol
Copy link
Owner

jsocol commented Dec 5, 2023

I'm definitely open to this if you want to open a PR!

@TreyWW
Copy link
Author

TreyWW commented Dec 5, 2023

Amazing, thank you for replying @jsocol!

I'll try and make some code snippets and let you know how it goes, I'll create a PR if I think it works.
Or would you like me to create a blank/draft PR so that somebody else could add this?
I wasn't planning on adding it myself, was more of a suggestion, but i'm happy to attempt it

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants