Skip to content

Commit

Permalink
fix(shares): Wrap exceptions from password validation to set code to 400
Browse files Browse the repository at this point in the history
This fixes a regression that bad password returned 403 instead of 400
 because of previous changes.

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Dec 12, 2024
1 parent 28d7206 commit 17007f6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ protected function verifyPassword($password) {
}

// Let others verify the password
$this->dispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));
try {
$this->dispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));
} catch (HintException $e) {
/* Wrap in a 400 bad request error */
throw new HintException($e->getMessage(), $e->getHint(), 400, $e);
}
}

/**
Expand Down Expand Up @@ -780,7 +785,7 @@ public function createShare(IShare $share) {
* @param IShare $share
* @return IShare The share object
* @throws \InvalidArgumentException
* @throws GenericShareException
* @throws HintException
*/
public function updateShare(IShare $share, bool $onlyValid = true) {
$expirationDateUpdated = false;
Expand Down

0 comments on commit 17007f6

Please sign in to comment.