From 17007f6b8dae214355c164b274915413628cb5d0 Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Tue, 10 Dec 2024 15:27:38 +0100 Subject: fix(shares): Wrap exceptions from password validation to set code to 400 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a regression that bad password returned 403 instead of 400 because of previous changes. Signed-off-by: Côme Chilliet --- lib/private/Share20/Manager.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index ea338937e2a..219f3d86380 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -112,7 +112,12 @@ class Manager implements IManager { } // 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); + } } /** @@ -780,7 +785,7 @@ class Manager implements IManager { * @param IShare $share * @return IShare The share object * @throws \InvalidArgumentException - * @throws GenericShareException + * @throws HintException */ public function updateShare(IShare $share, bool $onlyValid = true) { $expirationDateUpdated = false; -- cgit v1.2.3