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 {
|
||||
$response = new TemplateResponse(
|
||||
'core',
|
||||
'429',
|
||||
[],
|
||||
'403',
|
||||
[
|
||||
'message' => $exception->getMessage(),
|
||||
],
|
||||
'guest'
|
||||
);
|
||||
$response->setStatus($exception->getCode());
|
||||
|
|
|
@ -212,6 +212,10 @@ class Throttler {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ($ip === '') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$cutoffTime = (new \DateTime())
|
||||
->sub($this->getCutoff(43200))
|
||||
->getTimestamp();
|
||||
|
|
|
@ -270,8 +270,10 @@ class RateLimitingMiddlewareTest extends TestCase {
|
|||
$result = $this->rateLimitingMiddleware->afterException($controller, 'testMethod', new RateLimitExceededException());
|
||||
$expected = new TemplateResponse(
|
||||
'core',
|
||||
'429',
|
||||
[],
|
||||
'403',
|
||||
[
|
||||
'message' => 'Rate limit exceeded',
|
||||
],
|
||||
'guest'
|
||||
);
|
||||
$expected->setStatus(429);
|
||||
|
|
Loading…
Reference in New Issue