Skip to content

Commit 93e8a85

Browse files
committed
MAGE-891: remove non authenticated user token renewal
1 parent fc7cb9b commit 93e8a85

File tree

3 files changed

+1
-29
lines changed

3 files changed

+1
-29
lines changed

Helper/InsightsHelper.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ class InsightsHelper
2828
/** @var int */
2929
public const ALGOLIA_USER_TOKEN_MAX_LENGTH = 64;
3030

31-
/** @var int */
32-
public const ALGOLIA_USER_TOKEN_DEFAULT_LIFETIME = 15768000; // 6 months
33-
3431
/** @var string */
3532
public const QUOTE_ITEM_QUERY_PARAM = 'algoliasearch_query_param';
3633

@@ -160,30 +157,6 @@ public function setAuthenticatedUserToken(Customer $customer): string|null
160157
return $userToken;
161158
}
162159

163-
/**
164-
* Sets a token for a non-authenticated user
165-
*
166-
* @return void
167-
*/
168-
public function setNonAuthenticatedUserToken(): void
169-
{
170-
$metaData = $this->cookieMetadataFactory->createPublicCookieMetadata()
171-
->setDuration(InsightsHelper::ALGOLIA_USER_TOKEN_DEFAULT_LIFETIME)
172-
->setPath('/')
173-
->setHttpOnly(false)
174-
->setSecure(false);
175-
176-
try {
177-
$this->cookieManager->setPublicCookie(
178-
InsightsHelper::ALGOLIA_ANON_USER_TOKEN_COOKIE_NAME,
179-
(string) $this->cookieManager->getCookie(InsightsHelper::ALGOLIA_ANON_USER_TOKEN_COOKIE_NAME),
180-
$metaData
181-
);
182-
} catch (LocalizedException $e) {
183-
$this->logger->error("Error writing anonymous user cookie: " . $e->getMessage());
184-
}
185-
}
186-
187160
/**
188161
* @param int|null $storeId
189162
* @return bool

Observer/Insights/CookieRefresherObserver.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public function execute(Observer $observer): void
3232
{
3333
if ($this->customerSession->isLoggedIn()) {
3434
$this->insightsHelper->setAuthenticatedUserToken($this->customerSession->getCustomer());
35-
} else {
36-
$this->insightsHelper->setNonAuthenticatedUserToken();
3735
}
3836
}
3937
}

Observer/Insights/CustomerLogout.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function execute(\Magento\Framework\Event\Observer $observer): void
4747
try {
4848
$this->cookieManager->setPublicCookie(self::UNSET_AUTHENTICATION_USER_TOKEN_COOKIE_NAME, 1, $metaDataUnset);
4949
$this->cookieManager->deleteCookie(InsightsHelper::ALGOLIA_CUSTOMER_USER_TOKEN_COOKIE_NAME, $metadata);
50+
$this->cookieManager->deleteCookie(InsightsHelper::ALGOLIA_ANON_USER_TOKEN_COOKIE_NAME, $metadata);
5051
} catch (LocalizedException $e) {
5152
$this->logger->error("Error writing Algolia customer cookies: " . $e->getMessage());
5253
}

0 commit comments

Comments
 (0)