]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files_sharing): Fix error messages from password policy fix/fix-share-creation-error-messages 49361/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 19 Nov 2024 08:40:26 +0000 (09:40 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 19 Nov 2024 08:40:26 +0000 (09:40 +0100)
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>
apps/files_sharing/lib/Controller/ShareAPIController.php

index 71f73f777a5d9c4428a55870fb680fb1adbf49d7..99242761b291b33a62ed8fc0c1990698136f57d8 100644 (file)
@@ -37,6 +37,7 @@ use OCP\Files\InvalidPathException;
 use OCP\Files\IRootFolder;
 use OCP\Files\Node;
 use OCP\Files\NotFoundException;
+use OCP\HintException;
 use OCP\IConfig;
 use OCP\IDateTimeZone;
 use OCP\IGroupManager;
@@ -49,7 +50,6 @@ use OCP\Lock\ILockingProvider;
 use OCP\Lock\LockedException;
 use OCP\Mail\IMailer;
 use OCP\Server;
-use OCP\Share\Exceptions\GenericShareException;
 use OCP\Share\Exceptions\ShareNotFound;
 use OCP\Share\IManager;
 use OCP\Share\IProviderFactory;
@@ -811,7 +811,7 @@ class ShareAPIController extends OCSController {
 
                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) {
@@ -1357,7 +1357,7 @@ class ShareAPIController extends OCSController {
 
                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) {
@@ -1445,7 +1445,7 @@ class ShareAPIController extends OCSController {
 
                try {
                        $this->shareManager->acceptShare($share, $this->userId);
-               } catch (GenericShareException $e) {
+               } catch (HintException $e) {
                        $code = $e->getCode() === 0 ? 403 : $e->getCode();
                        throw new OCSException($e->getHint(), (int)$code);
                } catch (\Exception $e) {