From 2a9c1c56587cff14333033579de94cacfc78d26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Tue, 19 Dec 2023 17:27:55 +0100 Subject: [PATCH] Increase limit for the dashboard and do it by user --- app/api/views/alias.py | 5 ++--- app/dashboard/views/index.py | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/api/views/alias.py b/app/api/views/alias.py index 9e593f31..93859807 100644 --- a/app/api/views/alias.py +++ b/app/api/views/alias.py @@ -31,6 +31,7 @@ from app.models import Alias, Contact, Mailbox, AliasMailbox @deprecated @api_bp.route("/aliases", methods=["GET", "POST"]) @require_api_auth +@limiter.limit("10/minute", key_func=lambda: g.user.id) def get_aliases(): """ Get aliases @@ -72,10 +73,8 @@ def get_aliases(): @api_bp.route("/v2/aliases", methods=["GET", "POST"]) -@limiter.limit( - "5/minute", -) @require_api_auth +@limiter.limit("10/minute", key_func=lambda: g.user.id) def get_aliases_v2(): """ Get aliases diff --git a/app/dashboard/views/index.py b/app/dashboard/views/index.py index 6a145332..829f1702 100644 --- a/app/dashboard/views/index.py +++ b/app/dashboard/views/index.py @@ -57,10 +57,7 @@ def get_stats(user: User) -> Stats: methods=["POST"], exempt_when=lambda: request.form.get("form-name") != "create-random-email", ) -@limiter.limit( - "5/minute", - methods=["GET"], -) +@limiter.limit("10/minute", methods=["GET"], key_func=lambda: current_user.id) @login_required @parallel_limiter.lock( name="alias_creation",