Skip to content

Commit 8f58ae5

Browse files
come-ncbackportbot[bot]
authored andcommitted
fix(files_sharing): Fix error messages from password policy
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 <come.chilliet@nextcloud.com> [skip ci]
1 parent c62ce6f commit 8f58ae5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use OCP\Files\IRootFolder;
3535
use OCP\Files\Node;
3636
use OCP\Files\NotFoundException;
37+
use OCP\HintException;
3738
use OCP\IConfig;
3839
use OCP\IDateTimeZone;
3940
use OCP\IGroupManager;
@@ -46,7 +47,6 @@
4647
use OCP\Lock\LockedException;
4748
use OCP\Mail\IMailer;
4849
use OCP\Server;
49-
use OCP\Share\Exceptions\GenericShareException;
5050
use OCP\Share\Exceptions\ShareNotFound;
5151
use OCP\Share\IManager;
5252
use OCP\Share\IProviderFactory;
@@ -810,7 +810,7 @@ public function createShare(
810810

811811
try {
812812
$share = $this->shareManager->createShare($share);
813-
} catch (GenericShareException $e) {
813+
} catch (HintException $e) {
814814
$code = $e->getCode() === 0 ? 403 : $e->getCode();
815815
throw new OCSException($e->getHint(), $code);
816816
} catch (\Exception $e) {
@@ -1351,7 +1351,7 @@ public function updateShare(
13511351

13521352
try {
13531353
$share = $this->shareManager->updateShare($share);
1354-
} catch (GenericShareException $e) {
1354+
} catch (HintException $e) {
13551355
$code = $e->getCode() === 0 ? 403 : $e->getCode();
13561356
throw new OCSException($e->getHint(), (int)$code);
13571357
} catch (\Exception $e) {

0 commit comments

Comments
 (0)