From a7f4f0c737bdd712df88de74ab978966b4eb32a6 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 4 May 2023 10:55:34 +0200 Subject: [PATCH] output nicer message when hitting rate limit Signed-off-by: Michael Kaufmann --- lib/Froxlor/Http/RateLimiter.php | 9 ++++++++- templates/Froxlor/misc/ratelimithint.html.twig | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 templates/Froxlor/misc/ratelimithint.html.twig diff --git a/lib/Froxlor/Http/RateLimiter.php b/lib/Froxlor/Http/RateLimiter.php index 116feb49..0c78c38e 100644 --- a/lib/Froxlor/Http/RateLimiter.php +++ b/lib/Froxlor/Http/RateLimiter.php @@ -2,7 +2,9 @@ namespace Froxlor\Http; +use Froxlor\Froxlor; use Froxlor\Settings; +use Froxlor\UI\Panel\UI; class RateLimiter { @@ -33,7 +35,12 @@ class RateLimiter if ($remaining <= 0) { header('HTTP/1.1 429 Too Many Requests'); header("Retry-After: $reset"); - exit(); + UI::twig()->addGlobal('install_mode', '1'); + echo UI::twig()->render('Froxlor/misc/ratelimithint.html.twig', [ + 'retry' => $reset, + 'installdir' => Froxlor::getInstallDir() + ]); + die(); } // Decrement the remaining requests and update the headers diff --git a/templates/Froxlor/misc/ratelimithint.html.twig b/templates/Froxlor/misc/ratelimithint.html.twig new file mode 100644 index 00000000..997d969d --- /dev/null +++ b/templates/Froxlor/misc/ratelimithint.html.twig @@ -0,0 +1,17 @@ +{% extends "Froxlor/base.html.twig" %} + +{% block content %} +
+ +
+{% endblock %}