fix: viewing shared wishlist by hash

This commit is contained in:
grandeljay 2023-09-07 15:16:17 +02:00
parent e7893e8de2
commit 56993052b4
3 changed files with 3 additions and 6 deletions

View file

@ -148,12 +148,9 @@ switch ($_SERVER['REQUEST_METHOD']) {
http_response_code(404);
}
} elseif ($getWishlistFromHash) {
/**
* Get wishlist by hash
*/
$wishlist = Wishlist::getFromHash($_GET['wishlist_hash']);
if ($wishlist->exists) {
if ($wishlist instanceof Wishlist) {
$response['results'] = $wishlist;
} else {
http_response_code(404);

View file

@ -33,7 +33,7 @@ class Wishlist
return $wishlist;
}
public static function getFromHash(string $hash): self
public static function getFromHash(string $hash): self|false
{
global $database;

View file

@ -17,7 +17,7 @@ $page->scripts['wish'] = 'src/assets/js/parts/wish.js';
$page->scripts['wishlist-filter-priority'] = 'src/assets/js/parts/wishlist-filter-priority.js';
$page->scripts['wishlists'] = 'src/assets/js/parts/wishlists.js';
if (!$wishlist->exists) {
if (false === $wishlist) {
$page->errorDocument(404, $wishlist);
}