File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 9
9
10
10
class CustomerLogout implements ObserverInterface
11
11
{
12
+ public const UNSET_AUTHENTICATION_USER_TOKEN_COOKIE_NAME = "unset_authentication_token " ;
12
13
/**
13
14
* @var PhpCookieManager
14
15
*/
@@ -42,9 +43,15 @@ public function __construct(
42
43
public function execute (\Magento \Framework \Event \Observer $ observer )
43
44
{
44
45
if ($ this ->cookieManager ->getCookie (InsightsHelper::ALGOLIA_CUSTOMER_USER_TOKEN_COOKIE_NAME )) {
46
+ $ metaDataUnset = $ this ->cookieMetadataFactory ->createPublicCookieMetadata ()
47
+ ->setDurationOneYear ()
48
+ ->setPath ('/ ' )
49
+ ->setHttpOnly (false )
50
+ ->setSecure (false );
51
+ $ this ->cookieManager ->setPublicCookie (self ::UNSET_AUTHENTICATION_USER_TOKEN_COOKIE_NAME , 1 , $ metaDataUnset );
45
52
$ metadata = $ this ->cookieMetadataFactory ->createCookieMetadata ();
46
53
$ metadata ->setPath ('/ ' );
47
54
$ this ->cookieManager ->deleteCookie (InsightsHelper::ALGOLIA_CUSTOMER_USER_TOKEN_COOKIE_NAME , $ metadata );
48
55
}
49
56
}
50
- }
57
+ }
Original file line number Diff line number Diff line change 3
3
'jquery' ,
4
4
'algoliaAnalytics' ,
5
5
'algoliaBundle' ,
6
- 'algoliaCommon'
6
+ 'algoliaCommon' ,
7
+ 'mage/cookies'
7
8
] ,
8
9
function ( $ , algoliaAnalyticsWrapper , algoliaBundle ) {
9
10
algoliaAnalytics = algoliaAnalyticsWrapper . default ;
@@ -58,8 +59,13 @@ define(
58
59
algoliaAnalytics . addAlgoliaAgent ( userAgent ) ;
59
60
60
61
var userToken = getCookie ( 'aa-search' ) ;
61
- if ( userToken && userToken !== '' ) algoliaAnalytics . setUserToken ( userToken ) ;
62
-
62
+ var unsetAuthenticationToken = getCookie ( 'unset_authentication_token' ) ;
63
+ if ( userToken && userToken !== '' ) {
64
+ algoliaAnalytics . setAuthenticatedUserToken ( userToken ) ;
65
+ } else if ( unsetAuthenticationToken && unsetAuthenticationToken !== '' ) {
66
+ algoliaAnalytics . setAuthenticatedUserToken ( 'undefined' ) ;
67
+ $ . mage . cookies . clear ( 'unset_authentication_token' ) ;
68
+ }
63
69
} ,
64
70
65
71
addSearchParameters : function ( ) {
You can’t perform that action at this time.
0 commit comments