diff options
author | Joas Schilling <coding@schilljs.com> | 2022-06-13 10:30:51 +0300 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2022-06-13 11:38:40 +0300 |
commit | fa2d3ede52198e7ba0db0dcfb6599714288d0898 (patch) | |
tree | 4771d919d858effb88858010542d198bf62c9310 | |
parent | be236efd2bc80dff914d76fd24777f4766fcb590 (diff) |
Correctly log failed attempts
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/cloud_federation_api/lib/Controller/RequestHandlerController.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php index 02105fb3f9c..4c16c565d62 100644 --- a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php +++ b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php @@ -157,19 +157,23 @@ class RequestHandlerController extends Controller { $shareWith = $this->mapUid($shareWith); if (!$this->userManager->userExists($shareWith)) { - return new JSONResponse( + $response = new JSONResponse( ['message' => 'User "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()], Http::STATUS_BAD_REQUEST ); + $response->throttle(); + return $response; } } if ($shareType === 'group') { if (!$this->groupManager->groupExists($shareWith)) { - return new JSONResponse( + $response = new JSONResponse( ['message' => 'Group "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()], Http::STATUS_BAD_REQUEST ); + $response->throttle(); + return $response; } } @@ -252,10 +256,12 @@ class RequestHandlerController extends Controller { Http::STATUS_BAD_REQUEST ); } catch (ShareNotFound $e) { - return new JSONResponse( + $response = new JSONResponse( ['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST ); + $response->throttle(); + return $response; } catch (ActionNotSupportedException $e) { return new JSONResponse( ['message' => $e->getMessage()], @@ -264,7 +270,9 @@ class RequestHandlerController extends Controller { } catch (BadRequestException $e) { return new JSONResponse($e->getReturnMessage(), Http::STATUS_BAD_REQUEST); } catch (AuthenticationFailedException $e) { - return new JSONResponse(["message" => "RESOURCE_NOT_FOUND"], Http::STATUS_FORBIDDEN); + $response = new JSONResponse(['message' => 'RESOURCE_NOT_FOUND'], Http::STATUS_FORBIDDEN); + $response->throttle(); + return $response; } catch (\Exception $e) { return new JSONResponse( ['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()], |