From 7e62bd74a34a345a56a75a738155b80b782dbffe Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 3 Feb 2023 13:00:49 +0100 Subject: [PATCH] Fix admin logout --- admin/index.php | 4 ++++ system/logout.php | 18 ++++++++++++++++++ system/pages/account/logout.php | 17 +---------------- system/templates/admin.login.html.twig | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 system/logout.php diff --git a/admin/index.php b/admin/index.php index a24df186..15f6e730 100644 --- a/admin/index.php +++ b/admin/index.php @@ -47,6 +47,10 @@ require ADMIN . 'includes/functions.php'; $twig->addGlobal('config', $config); $twig->addGlobal('status', $status); +if (ACTION == 'logout') { + require SYSTEM . 'logout.php'; +} + // if we're not logged in - show login box if(!$logged || !admin()) { $page = 'login'; diff --git a/system/logout.php b/system/logout.php new file mode 100644 index 00000000..a7f5d8fd --- /dev/null +++ b/system/logout.php @@ -0,0 +1,18 @@ +isLoaded()) { + if($hooks->trigger(HOOK_LOGOUT, ['account_id' => $account_logged->getId()])) { + unsetSession('account'); + unsetSession('password'); + unsetSession('remember_me'); + + $logged = false; + unset($account_logged); + + if(isset($_REQUEST['redirect'])) + { + header('Location: ' . urldecode($_REQUEST['redirect'])); + exit; + } + } +} diff --git a/system/pages/account/logout.php b/system/pages/account/logout.php index bbd5e5d1..55e15585 100644 --- a/system/pages/account/logout.php +++ b/system/pages/account/logout.php @@ -17,21 +17,6 @@ if(!$logged) { return; } -if(isset($account_logged) && $account_logged->isLoaded()) { - if($hooks->trigger(HOOK_LOGOUT, ['account_id' => $account_logged->getId()])) { - unsetSession('account'); - unsetSession('password'); - unsetSession('remember_me'); - - $logged = false; - unset($account_logged); - - if(isset($_REQUEST['redirect'])) - { - header('Location: ' . urldecode($_REQUEST['redirect'])); - exit; - } - } -} +require SYSTEM . 'logout.php'; $twig->display('account.logout.html.twig'); diff --git a/system/templates/admin.login.html.twig b/system/templates/admin.login.html.twig index aed34a5b..2abc4eb1 100644 --- a/system/templates/admin.login.html.twig +++ b/system/templates/admin.login.html.twig @@ -18,7 +18,7 @@
-
+