output nicer message when hitting rate limit
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace Froxlor\Http;
|
namespace Froxlor\Http;
|
||||||
|
|
||||||
|
use Froxlor\Froxlor;
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
|
use Froxlor\UI\Panel\UI;
|
||||||
|
|
||||||
class RateLimiter
|
class RateLimiter
|
||||||
{
|
{
|
||||||
@@ -33,7 +35,12 @@ class RateLimiter
|
|||||||
if ($remaining <= 0) {
|
if ($remaining <= 0) {
|
||||||
header('HTTP/1.1 429 Too Many Requests');
|
header('HTTP/1.1 429 Too Many Requests');
|
||||||
header("Retry-After: $reset");
|
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
|
// Decrement the remaining requests and update the headers
|
||||||
|
|||||||
17
templates/Froxlor/misc/ratelimithint.html.twig
Normal file
17
templates/Froxlor/misc/ratelimithint.html.twig
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{% extends "Froxlor/base.html.twig" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container my-auto">
|
||||||
|
<div class="alert alert-warning fade show" role="alert">
|
||||||
|
<h4 class="alert-heading">
|
||||||
|
Whoops!
|
||||||
|
</h4>
|
||||||
|
<p>It seems like you've hit the rate limit.</p>
|
||||||
|
<p>Please slow down your requests and retry after {{ retry|date('d.m.Y H:i:s') }}</p>
|
||||||
|
<hr>
|
||||||
|
<p class="mt-1 text-center">
|
||||||
|
<a href="" class="btn btn-primary" title="Reload page">Reload</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user