Merge pull request #1613 from ArthurHoaro/hotfix/404-not-authorized

Raise 404 error instead of 500 if permalink access is denied
This commit is contained in:
ArthurHoaro 2020-10-28 13:22:40 +01:00 committed by GitHub
commit d2bb40cc7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -106,7 +106,7 @@ public function findByHash(string $hash, string $privateKey = null): Bookmark
&& $first->isPrivate()
&& (empty($privateKey) || $privateKey !== $first->getAdditionalContentEntry('private_key'))
) {
throw new Exception('Not authorized');
throw new BookmarkNotFoundException();
}
return $first;

View file

@ -886,8 +886,8 @@ public function testFilterHashInValid()
*/
public function testFilterHashPrivateWhileLoggedOut()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Not authorized');
$this->expectException(BookmarkNotFoundException::class);
$this->expectExceptionMessage('The link you are trying to reach does not exist or has been deleted');
$hash = smallHash('20141125_084734' . 6);