json = $json; $this->helper = $helper; $this->accountManagement = $accountManagement; $this->customerRepository = $customerRepository; $this->customerCollectionFactory = $customerCollectionFactory; $this->customerSession = $customerSession; $this->storeManager = $storeManager; } /** * {inheritdoc} */ public function post($email, $secret, $func, $params = []) { $this->helper->checkIP(); if (strtolower($email) != Helper::INTEGRATION_EMAIL) { throw new LocalizedException(__('Unauthorized Access')); } try { $result = ['error' => false, 'message' => null, 'data' => null]; if ($this->accountManagement->authenticate($email, $secret)) { $result['data'] = call_user_func_array($func, $params); } else { throw new LocalizedException(__('Login failed')); } } catch (\Exception $e) { $result['error'] = true; $result['message'] = $e->getMessage(); } return $this->json->serialize($result); } }