Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 18669f5

Browse files
authored
Add user token variable (#10)
* Add user token variable * Add a unique token to registered users
1 parent 5f1713d commit 18669f5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

apisearch.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,18 @@ public function hookHeader()
328328
$admin_url = $admin_url == ""
329329
? ApisearchDefaults::DEFAULT_AS_ADMIN_URL
330330
: $admin_url;
331-
331+
332+
$user_id = Context::getContext()->customer->id;
333+
if($user_id == null){
334+
$user_id = Context::getContext()->cart->id_guest;
335+
$token = sha1('apisearch'. $user_id . $_SERVER['REMOTE_ADDR']. date('Y-m-d'));
336+
}else{
337+
$token = sha1('apisearch'. $user_id);
338+
}
339+
332340
Media::addJsDef(array(
333341
'admin_url' => $admin_url,
342+
'apisearch_user_token' => $token,
334343
'index_id' => Configuration::get('AS_INDEX', Context::getContext()->language->id),
335344
));
336345

0 commit comments

Comments
 (0)