Skip to content

Commit

Permalink
Merge pull request #32855 from nextcloud/backport/32843/stable23
Browse files Browse the repository at this point in the history
[stable23] Correctly log failed attempts
  • Loading branch information
blizzz authored Jun 13, 2022
2 parents d41f5b4 + 9ff6b1a commit 6da9417
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,23 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
$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;
}
}

Expand Down Expand Up @@ -252,10 +256,12 @@ public function receiveNotification($notificationType, $resourceType, $providerI
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()],
Expand All @@ -264,7 +270,9 @@ public function receiveNotification($notificationType, $resourceType, $providerI
} 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()],
Expand Down

0 comments on commit 6da9417

Please sign in to comment.