diff --git a/src/app/controllers/UserController.php b/src/app/controllers/UserController.php index 5518b7a..aa271bc 100644 --- a/src/app/controllers/UserController.php +++ b/src/app/controllers/UserController.php @@ -36,15 +36,12 @@ public function logoutUser($log = true) if ($log) { $this->log($username, "Logged out", auth_logs); } - - setcookie("login_cookie", "", time() - 3600, '/'); - session_unset(); - $_SESSION = []; - $_SESSION = array(); - session_destroy(); - Util::redirect("/auth/login.php"); + Util::redirect("/auth/login.php?action=logout"); } + + + public function getUserArray() { return $this->UserArray(); diff --git a/src/auth/login.php b/src/auth/login.php index 0c74bde..8fd859c 100644 --- a/src/auth/login.php +++ b/src/auth/login.php @@ -7,9 +7,23 @@ Session::init(); -if (Session::isLogged()) { - Util::redirect('/'); + +if (Util::securevar($_SERVER['REQUEST_METHOD']) === 'GET') { + if (isset($_GET['action'])) { + $data = Util::securevar($_GET['action']); + + if ($data === 'logout') { + setcookie("login_cookie", "", time() - 3600, '/'); + session_unset(); + $_SESSION = []; + session_destroy(); + Util::redirect('/auth/login.php'); + } + } } + + + if (Util::securevar($_SERVER['REQUEST_METHOD']) === 'POST') { if (isset($_POST)) { $data = Util::securevar($_POST); diff --git a/src/auth/logout.php b/src/auth/logout.php index cd5cdd1..adc1b2e 100644 --- a/src/auth/logout.php +++ b/src/auth/logout.php @@ -10,5 +10,3 @@ $user = new UserController(); $user->logoutUser(); - -Util::redirect('/auth/login.php'); diff --git a/src/index.php b/src/index.php index 8721492..1bf608f 100644 --- a/src/index.php +++ b/src/index.php @@ -204,7 +204,7 @@ $loginfails = Session::get("loginfails"); if ($loginfails > 0) : ?>
- Security Warning: failed login attempts + Security Warning: failed login attempts