From c0307c6e9161e38d8ea3f35095d060ea503ae3b4 Mon Sep 17 00:00:00 2001 From: De Cramer Oliver Date: Thu, 5 Dec 2024 13:11:35 +0100 Subject: [PATCH] fix: Not unique tokens generated for logged in customers --- src/CommandHandler/Wishlist/CreateNewWishlistHandler.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CommandHandler/Wishlist/CreateNewWishlistHandler.php b/src/CommandHandler/Wishlist/CreateNewWishlistHandler.php index 2040cf5c..273a56d1 100644 --- a/src/CommandHandler/Wishlist/CreateNewWishlistHandler.php +++ b/src/CommandHandler/Wishlist/CreateNewWishlistHandler.php @@ -57,10 +57,13 @@ public function __invoke(CreateNewWishlist $createNewWishlist): int /** @var WishlistInterface $wishlist */ $wishlist = $this->wishlistFactory->createNew(); $wishlists = $this->wishlistRepository->findAllByAnonymous($wishlistCookieToken); - } - if ('' !== $wishlistCookieToken) { - $wishlist->setToken($wishlistCookieToken); + if ('' !== $wishlistCookieToken) { + // Set token only for guest users, if not allow unique tokens to be generated. + // This allows us to use the token in the api's and share whishlists created in the web with those + // created with api's. + $wishlist->setToken($wishlistCookieToken); + } } if (null !== $createNewWishlist->getChannelCode()) {