forked from kuzmany/mautic-prestashop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthorization.php
More file actions
36 lines (32 loc) · 1.05 KB
/
authorization.php
File metadata and controls
36 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
include(dirname(__FILE__) . '/../../config/config.inc.php');
session_name("mauticprestashop");
session_start();
require(dirname(__FILE__) . '/lib/api/vendor/autoload.php');
if (Tools::getIsset('reset')) {
unset($_SESSION['oauth']);
}
$error = false;
$module = ModuleCore::getInstanceByName("mauticprestashop");
try {
$auth = $module->mautic_auth(Tools::getIsset('reset'));
if ($auth) {
if ($auth->validateAccessToken()) {
if ($auth->accessTokenUpdated()) {
$accessTokenData = $auth->getAccessTokenData();
Configuration::updateValue('MAUTICPRESTASHOP_ACCESS_TOKEN_DATA', serialize($accessTokenData), false, Tools::getValue('id_shop_group'), Tools::getValue('id_shop'));
}
}
}
} catch (Exception $e) {
$error = true;
}
if (!Tools::getIsset('back')) {
$redirect = Tools::secureReferrer($_SERVER['HTTP_REFERER']);
} else {
$redirect = unserialize(base64_decode(urldecode(Tools::getValue('back'))));
}
if ($error) {
$redirect .= '&error=1';
}
Tools::redirect($redirect);