Skip to content

Instantly share code, notes, and snippets.

@williankeller
Created July 12, 2018 19:47
Show Gist options
  • Save williankeller/8eede31877f0e36283e08a83b28e2f80 to your computer and use it in GitHub Desktop.
Save williankeller/8eede31877f0e36283e08a83b28e2f80 to your computer and use it in GitHub Desktop.
<?php
public function afterGetUserId(\Magento\Webapi\Model\Authorization\TokenUserContext $subject, $result)
{
/** @param Request $requestHeader **/
$integration = $this->requestHeader->getHeader('custID');
if (!empty($integration)) {
static $customer = null;
if ($customer) {
return $customer->getId();
}
// Get customer account in Magento by integration ID.
$customer = $this->accountManagement->getByMagento($integration);
if (!empty($customer)) {
return $customer->getId();
}
}
// Return default context ID.
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment