summaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework/Middleware
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-04-23 10:21:14 +0200
committerJoas Schilling <coding@schilljs.com>2021-04-27 13:55:34 +0200
commit174f4dd0438ea59e311f5201f59ece3301976df9 (patch)
tree60658b306854fd3d8a66257d0d5e23b06cd270d8 /lib/private/AppFramework/Middleware
parentbf1c875425e7fdf5ffd3c233ddf1f567428b4168 (diff)
downloadnextcloud-server-174f4dd0438ea59e311f5201f59ece3301976df9.tar.gz
nextcloud-server-174f4dd0438ea59e311f5201f59ece3301976df9.zip
Fix ratelimit template
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/AppFramework/Middleware')
-rw-r--r--lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php21
1 files changed, 7 insertions, 14 deletions
diff --git a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php
index 712becb3be5..f5960880546 100644
--- a/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php
+++ b/lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php
@@ -27,7 +27,7 @@ namespace OC\AppFramework\Middleware\Security;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OC\Security\RateLimiting\Exception\RateLimitExceededException;
use OC\Security\RateLimiting\Limiter;
-use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Middleware;
use OCP\IRequest;
@@ -110,21 +110,14 @@ class RateLimitingMiddleware extends Middleware {
public function afterException($controller, $methodName, \Exception $exception) {
if ($exception instanceof RateLimitExceededException) {
if (stripos($this->request->getHeader('Accept'),'html') === false) {
- $response = new JSONResponse(
- [
- 'message' => $exception->getMessage(),
- ],
- $exception->getCode()
- );
+ $response = new DataResponse([], $exception->getCode());
} else {
$response = new TemplateResponse(
- 'core',
- '403',
- [
- 'file' => $exception->getMessage()
- ],
- 'guest'
- );
+ 'core',
+ '429',
+ [],
+ TemplateResponse::RENDER_AS_GUEST
+ );
$response->setStatus($exception->getCode());
}