Skip to content

Commit

Permalink
Fix token for multishop
Browse files Browse the repository at this point in the history
  • Loading branch information
PrestaSafe committed Nov 3, 2023
1 parent 821608b commit dc3d7ff
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion controllers/front/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PrettyBlocksAjaxModuleFrontController extends ModuleFrontController

public function __construct()
{
$this->ajax_token = Configuration::get('_PRETTYBLOCKS_TOKEN_');
$this->ajax_token = Configuration::getGlobalValue('_PRETTYBLOCKS_TOKEN_');
$this->translator = Context::getContext()->getTranslator();
parent::__construct();
}
Expand Down
7 changes: 5 additions & 2 deletions prettyblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct()
{
$this->name = 'prettyblocks';
$this->tab = 'administration';
$this->version = '3.0.1';
$this->version = '3.0.2';
$this->author = 'PrestaSafe';
$this->need_instance = 1;
$this->js_path = $this->_path . 'views/js/';
Expand Down Expand Up @@ -161,7 +161,7 @@ public function getContent()

private function loadDefault()
{
return Configuration::updateValue('_PRETTYBLOCKS_TOKEN_', Tools::passwdGen(25));
return Configuration::updateGlobalValue('_PRETTYBLOCKS_TOKEN_', Tools::passwdGen(25));
}

public function install()
Expand Down Expand Up @@ -224,6 +224,9 @@ public function hookdisplayHeader($params)
'priority' => 200,
]
);
$this->context->smarty->assign([
'prettyblocks' => true,
]);
// todo register css and js on iframe only from Hook
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AdminThemeManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function indexAction()
'type_search_here' => $translator->trans('Type your search here', [], 'Modules.Prettyblocks.Admin'),
],
'security_app' => [
'ajax_token' => \Configuration::get('_PRETTYBLOCKS_TOKEN_'),
'ajax_token' => \Configuration::getGlobalValue('_PRETTYBLOCKS_TOKEN_'),
'prettyblocks_version' => $module->version,
],
'css_build' => $css,
Expand Down
38 changes: 38 additions & 0 deletions upgrade/upgrade-3.0.2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Copyright (c) Since 2020 PrestaSafe and contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaSafe <[email protected]>
* @copyright Since 2020 PrestaSafe and contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaSafe
*/
if (!defined('_PS_VERSION_')) {
exit;
}

/**
* @param prettyblocks $module
*
* @return bool|string
*
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
*/
function upgrade_module_3_0_0($module)
{
Configuration::deleteByName('_PRETTYBLOCKS_TOKEN_');
Configuration::updateGlobalValue('_PRETTYBLOCKS_TOKEN_', Tools::passwdGen(25));

return true;
}

0 comments on commit dc3d7ff

Please sign in to comment.