429 template is NC20+ and fix getDelay for CLI
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
f585fbc391
commit
43d6921772
|
@ -114,8 +114,10 @@ class RateLimitingMiddleware extends Middleware {
|
||||||
} else {
|
} else {
|
||||||
$response = new TemplateResponse(
|
$response = new TemplateResponse(
|
||||||
'core',
|
'core',
|
||||||
'429',
|
'403',
|
||||||
[],
|
[
|
||||||
|
'message' => $exception->getMessage(),
|
||||||
|
],
|
||||||
'guest'
|
'guest'
|
||||||
);
|
);
|
||||||
$response->setStatus($exception->getCode());
|
$response->setStatus($exception->getCode());
|
||||||
|
|
|
@ -212,6 +212,10 @@ class Throttler {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($ip === '') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$cutoffTime = (new \DateTime())
|
$cutoffTime = (new \DateTime())
|
||||||
->sub($this->getCutoff(43200))
|
->sub($this->getCutoff(43200))
|
||||||
->getTimestamp();
|
->getTimestamp();
|
||||||
|
|
|
@ -270,8 +270,10 @@ class RateLimitingMiddlewareTest extends TestCase {
|
||||||
$result = $this->rateLimitingMiddleware->afterException($controller, 'testMethod', new RateLimitExceededException());
|
$result = $this->rateLimitingMiddleware->afterException($controller, 'testMethod', new RateLimitExceededException());
|
||||||
$expected = new TemplateResponse(
|
$expected = new TemplateResponse(
|
||||||
'core',
|
'core',
|
||||||
'429',
|
'403',
|
||||||
[],
|
[
|
||||||
|
'message' => 'Rate limit exceeded',
|
||||||
|
],
|
||||||
'guest'
|
'guest'
|
||||||
);
|
);
|
||||||
$expected->setStatus(429);
|
$expected->setStatus(429);
|
||||||
|
|
Loading…
Reference in New Issue