diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-04-27 15:18:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-27 15:18:02 +0200 |
commit | 48c50277a92b3b37fb4a9a9e7e20a487649b99db (patch) | |
tree | b8d730a31bec718a918d4a57b6685b5c42dd0f94 /lib | |
parent | c52a026f55c70bee22036d28dda01eae087e0c7a (diff) | |
parent | 13b37a5255cd0586c32b66cfda01b6014f09dcba (diff) | |
download | nextcloud-server-48c50277a92b3b37fb4a9a9e7e20a487649b99db.tar.gz nextcloud-server-48c50277a92b3b37fb4a9a9e7e20a487649b99db.zip |
Merge pull request #26718 from nextcloud/bugfix/noid/fix-ratelimit-template
Fix ratelimit template
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/Middleware/Security/RateLimitingMiddleware.php | 21 | ||||
-rw-r--r-- | lib/private/Template/Base.php | 4 |
2 files changed, 10 insertions, 15 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()); } diff --git a/lib/private/Template/Base.php b/lib/private/Template/Base.php index c95958ceea1..65d0ad469ff 100644 --- a/lib/private/Template/Base.php +++ b/lib/private/Template/Base.php @@ -168,7 +168,9 @@ class Base { if (!is_null($additionalParams)) { $_ = array_merge($additionalParams, $this->vars); foreach ($_ as $var => $value) { - ${$var} = $value; + if (!isset(${$var})) { + ${$var} = $value; + } } } |