From 2d4f84a2a1cbd1b520feb64ecaeb11d090f465ed Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Fri, 10 Jun 2022 04:28:14 +0200 Subject: [PATCH] Fix login and logout Signed-off-by: Marco Dickert --- src/ifm.js | 8 ++++++-- src/main.php | 11 ++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ifm.js b/src/ifm.js index 73f37e7..22c315f 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -33,7 +33,7 @@ function IFM(params) { * @param {string} content - HTML content of the modal * @param {object} options - options for the modal ({ large: false }) */ - this.showModal = function( content, options ) { + this.showModal = function( content, options, modal_options ) { options = options || {}; let modal = document.createElement( 'div' ); modal.classList.add( 'modal' ); @@ -66,6 +66,7 @@ function IFM(params) { formElements.first().focus(); } }) + .modal(modal_options) .modal('show'); }; @@ -1906,7 +1907,10 @@ function IFM(params) { dataType: "json", success: function(d) { if (d.status == "ERROR") { - self.showModal(Mustache.render(self.templates.login, {i18n: self.i18n}), {large: true}); + self.showModal(Mustache.render(self.templates.login, {i18n: self.i18n}), {large: true}, { + backdrop: 'static', + keyboard: false + }); var form = document.forms.loginForm; form.addEventListener('click', function(e) { e.preventDefault(); diff --git a/src/main.php b/src/main.php index 82b7457..2c5d4ff 100644 --- a/src/main.php +++ b/src/main.php @@ -188,11 +188,8 @@ f00bar; case "getI18N": return $this->getI18N($_REQUEST); case "logout": - $session_name = basename($this->config['root_dir']); - session_set_cookie_params(0, "/{$session_name}/"); - session_start(['cookie_path' => "/{$session_name}/",'name' => $session_name,]); + session_start(); unset($_SESSION); - session_destroy(); header("Location: " . strtok($_SERVER["REQUEST_URI"], '?')); exit; } @@ -997,9 +994,9 @@ f00bar; } if (session_status() !== PHP_SESSION_ACTIVE) { - $session_name = basename($this->config['root_dir']); - session_set_cookie_params(0, "/{$session_name}/"); - session_start(['cookie_path' => "/{$session_name}/",'name' => $session_name,]); + $cookie_path = dirname($_SERVER['REQUEST_URI']); + session_set_cookie_params(0, $cookie_path); + session_start(['cookie_path' => $cookie_path]); } if (isset($_SESSION['ifmauth']) && $_SESSION['ifmauth'] == true)