Skip to content

Commit

Permalink
fix(files_sharing): Fix error messages from password policy
Browse files Browse the repository at this point in the history
Exceptions thrown from password_policy may bubble up in share creation

or update when a password is used. Their message is meant to be shown

to the user. This always the case for HintException so we catch that

instead of the subclass GenericShareException.

Signed-off-by: Côme Chilliet <[email protected]>

[skip ci]
  • Loading branch information
come-nc authored and backportbot[bot] committed Dec 12, 2024
1 parent 9236da2 commit 3a44ae4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\HintException;
use OCP\IConfig;
use OCP\IDateTimeZone;
use OCP\IGroupManager;
Expand All @@ -80,7 +81,6 @@
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use OCP\Server;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IShare;
Expand Down Expand Up @@ -825,7 +825,7 @@ public function createShare(

try {
$share = $this->shareManager->createShare($share);
} catch (GenericShareException $e) {
} catch (HintException $e) {
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code);
} catch (\Exception $e) {
Expand Down Expand Up @@ -1360,7 +1360,7 @@ public function updateShare(

try {
$share = $this->shareManager->updateShare($share);
} catch (GenericShareException $e) {
} catch (HintException $e) {
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), (int)$code);
} catch (\Exception $e) {
Expand Down

0 comments on commit 3a44ae4

Please sign in to comment.