26 private $securityCookie;
34 private function getSecurityCookie()
37 return \Magento\Framework\App\ObjectManager::getInstance()->get(SecurityCookie::class);
39 return $this->securityCookie;
51 $integrationData = [];
53 $integrationId = (int)$this->
getRequest()->getParam(self::PARAM_INTEGRATION_ID);
56 if (!$integrationData) {
59 if ($integrationData[Info::DATA_SETUP_TYPE] == IntegrationModel::TYPE_CONFIG) {
60 throw new LocalizedException(
__(
"The integrations created in the config file can't be edited."));
64 $this->processData($integrationData);
66 $this->_auth->logout();
67 $this->getSecurityCookie()->setLogoutReasonCookie(
68 \
Magento\Security\Model\AdminSessionsManager::LOGOUT_REASON_USER_LOCKED
71 }
catch (\
Magento\Framework\Exception\AuthenticationException $e) {
72 $this->messageManager->addError($e->getMessage());
76 $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage()));
77 $this->
_getSession()->setIntegrationData($integrationData);
80 $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage()));
82 }
catch (\Exception $e) {
83 $this->_logger->critical($e);
84 $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage()));
101 $user = $this->_auth->getUser();
102 $user->performIdentityCheck($password);
116 $integrationData = $this->_integrationService->get($integrationId)->getData();
118 $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage()));
121 }
catch (\Exception $e) {
122 $this->_logger->critical($e);
123 $this->messageManager->addError(
__(
'Internal error. Check exception log for details.'));
128 return $integrationData;
138 $integrationId = $this->
getRequest()->getParam(self::PARAM_INTEGRATION_ID);
139 if ($integrationId) {
140 $this->
_redirect(
'*/*/edit', [
'id' => $integrationId]);
152 private function processData($integrationData)
157 if (!isset(
$data[
'resource'])) {
158 $integrationData[
'resource'] = [];
160 $integrationData = array_merge($integrationData,
$data);
161 if (!isset($integrationData[Info::DATA_ID])) {
162 $integration = $this->_integrationService->create($integrationData);
164 $integration = $this->_integrationService->update($integrationData);
166 if (!$this->
getRequest()->isXmlHttpRequest()) {
167 $this->messageManager->addSuccess(
169 'The integration \'%1\' has been saved.',
177 $this->jsonHelper->jsonEncode(
178 [
'integrationId' =>
$integration->getId(),
'isTokenExchange' => $isTokenExchange]
183 $this->messageManager->addError(
__(
'The integration was not saved.'));
_redirect($path, $arguments=[])
getIntegration($integrationId)