diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-08-01 22:28:08 +0200 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2024-08-06 16:25:10 +0200 |
commit | db28aa8cd14d40a671396778a06af10879b5d14a (patch) | |
tree | 1e0715112704d643e46076de1528e4375634cd80 /apps/files_sharing | |
parent | 69f01b1df6bf12657b7ddcf8c42ef3cf00c3ea84 (diff) | |
download | nextcloud-server-db28aa8cd14d40a671396778a06af10879b5d14a.tar.gz nextcloud-server-db28aa8cd14d40a671396778a06af10879b5d14a.zip |
fix(files_sharing): show proper share not found error message
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 8 | ||||
-rw-r--r-- | apps/files_sharing/templates/sharenotfound.php | 23 |
2 files changed, 27 insertions, 4 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index eef2f5f32bc..642065c9983 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -294,11 +294,11 @@ class ShareController extends AuthPublicShareController { } catch (ShareNotFound $e) { // The share does not exists, we do not emit an ShareLinkAccessedEvent $this->emitAccessShareHook($this->getToken(), 404, 'Share not found'); - throw new NotFoundException(); + throw new NotFoundException($this->l10n->t('This share does not exist or is no longer available')); } if (!$this->validateShare($share)) { - throw new NotFoundException(); + throw new NotFoundException($this->l10n->t('This share does not exist or is no longer available')); } $shareNode = $share->getNode(); @@ -309,7 +309,7 @@ class ShareController extends AuthPublicShareController { } catch (NotFoundException $e) { $this->emitAccessShareHook($share, 404, 'Share not found'); $this->emitShareAccessEvent($share, ShareController::SHARE_ACCESS, 404, 'Share not found'); - throw new NotFoundException(); + throw new NotFoundException($this->l10n->t('This share does not exist or is no longer available')); } // We can't get the path of a file share @@ -317,7 +317,7 @@ class ShareController extends AuthPublicShareController { if ($shareNode instanceof \OCP\Files\File && $path !== '') { $this->emitAccessShareHook($share, 404, 'Share not found'); $this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found'); - throw new NotFoundException(); + throw new NotFoundException($this->l10n->t('This share does not exist or is no longer available')); } } catch (\Exception $e) { $this->emitAccessShareHook($share, 404, 'Share not found'); diff --git a/apps/files_sharing/templates/sharenotfound.php b/apps/files_sharing/templates/sharenotfound.php new file mode 100644 index 00000000000..fe653d4ad5a --- /dev/null +++ b/apps/files_sharing/templates/sharenotfound.php @@ -0,0 +1,23 @@ +<?php +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +use OCP\IURLGenerator; +use OCP\Server; + +$urlGenerator = Server::get(IURLGenerator::class); +?> +<div class="body-login-container update"> + <div> + <svg xmlns="http://www.w3.org/2000/svg" height="70" viewBox="0 -960 960 960" width="70"> + <path fill="currentColor" d="m674-456-50-50 69-70-69-69 50-51 70 70 69-70 51 51-70 69 70 70-51 50-69-69-70 69Zm-290-24q-60 0-102-42t-42-102q0-60 42-102t102-42q60 0 102 42t42 102q0 60-42 102t-102 42ZM96-192v-92q0-26 12.5-47.5T143-366q55-32 116-49t125-17q64 0 125 17t116 49q22 13 34.5 34.5T672-284v92H96Z"/> + </svg> + </div> + <h2><?php p($l->t('Share not found')); ?></h2> + <p class="infogroup"><?php p($_['message'] ?: $l->t('This share does not exist or is no longer available')); ?></p> + <p><a class="button primary" href="<?php p($urlGenerator->linkTo('', 'index.php')) ?>"> + <?php p($l->t('Back to %s', [$theme->getName()])); ?> + </a></p> +</div> |