diff --git a/admin/themes/default/template/page_header_toolbar.tpl b/admin/themes/default/template/page_header_toolbar.tpl index 8aaaa9726..bf852d48a 100644 --- a/admin/themes/default/template/page_header_toolbar.tpl +++ b/admin/themes/default/template/page_header_toolbar.tpl @@ -115,9 +115,15 @@ }); {/if} - $('.process-icon-modules-list').parent('a').unbind().bind('click', function (){ - $('#modules_list_container').modal('show'); - openModulesList(); + $('.process-icon-modules-list').parent('a').unbind().bind('click', async function (){ + let loggedIn = await checkIfEmployeeIsLoggedIn(); + + if (loggedIn) { + $('#modules_list_container').modal('show'); + openModulesList(); + } else { + window.location = window.location.pathname; + } }); //]]> diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index 4daeaadf0..78331bd0c 100644 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -45,6 +45,18 @@ class AdminLoginControllerCore extends AdminController } } + public function init() + { + parent::init(); + + if ($this->ajax && Tools::getValue('action') == 'checkLoginStatus') { + $this->ajaxDie(json_encode(array( + 'status' => true, + 'is_logged_in' => $this->context->employee->isLoggedBack(), + ))); + } + } + public function setMedia() { $this->addJquery(); diff --git a/js/admin.js b/js/admin.js index 4d474721a..7b16f76bf 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1219,6 +1219,26 @@ function sendBulkAction(form, action) $(form).submit(); } +function checkIfEmployeeIsLoggedIn() { + return new Promise(function (resolve) { + $.ajax({ + url : window.location.pathname, + type: 'POST', + dataType: 'JSON', + data : { + ajax : '1', + controller : 'AdminLogin', + action : 'checkLoginStatus', + }, + success : function(response) { + if (response.status) { + resolve(response.is_logged_in); + } + } + }); + }); +} + function openModulesList() { if (!modules_list_loaded)