Skip to content

Commit bdc1447

Browse files
committed
Supporting Ajax calls
1 parent c067153 commit bdc1447

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

IntegrationInfoProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ public function updateIntegrationInfo($integrationInfo,$hash)
5959
$sql = "Insert Into " . $tableName . " (info) Values ('" . $integrationInfo ."')";
6060
$connection->query($sql);
6161
}
62+
else
63+
{
64+
$response->setStatusCode(\Magento\Framework\App\Response\Http::STATUS_CODE_401);
65+
$response->sendResponse();
66+
}
6267
}
6368

6469
private function isValidRequest($integrationInfo,$hash)

KnownUserHandler.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,33 @@ public function handleRequest($customerId, $secretKey, $observer)
2020
$configProvider = new IntegrationInfoProvider();
2121
$configText = $configProvider->getIntegrationInfo(true);
2222
$fullUrl = $this->getFullRequestUri();
23-
$result = \QueueIT\KnownUserV3\SDK\KnownUser::validateRequestByIntegrationConfig($fullUrl,
24-
$queueittoken, $configText,$customerId, $secretKey);
25-
23+
$currentUrlWithoutQueueitToken = preg_replace ( "/([\\?&])(" ."queueittoken". "=[^&]*)/i" , "" , $fullUrl);
24+
25+
$result = \QueueIT\KnownUserV3\SDK\KnownUser::validateRequestByIntegrationConfig(
26+
$currentUrlWithoutQueueitToken,
27+
$queueittoken,
28+
$configText,
29+
$customerId,
30+
$secretKey);
2631

2732
if($result->doRedirect())
2833
{
29-
$response = $action->getResponse();
30-
34+
$response = $action->getResponse();
35+
3136
$response->setHeader('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
3237
$response->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
3338
$response->setHeader('Pragma', 'no-cache');
34-
$response->setRedirect($result->redirectUrl)->sendResponse();
39+
40+
if(!$result->isAjaxResult)
41+
{
42+
$response->setRedirect($result->redirectUrl)->sendResponse();
43+
}
44+
else
45+
{
46+
$response->setHeader($result->getAjaxQueueRedirectHeaderKey(), $result->getAjaxRedirectUrl());
47+
$response->sendResponse();
48+
}
49+
3550
return;
3651
}
3752

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
},
1313
"require": {
14-
"queueit/knownuserv3": "*"
14+
"queueit/knownuserv3": "^3.5.1"
1515

1616
}
1717
}

0 commit comments

Comments
 (0)