From 03fc2c42ad58be3172c994d5b682bcf336d37166 Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 22 Mar 2025 03:11:47 -0700 Subject: [PATCH] Update w/ logout() method --- src/RaspAP/Auth/HTTPAuth.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/RaspAP/Auth/HTTPAuth.php b/src/RaspAP/Auth/HTTPAuth.php index d32a36ad..a28f9212 100755 --- a/src/RaspAP/Auth/HTTPAuth.php +++ b/src/RaspAP/Auth/HTTPAuth.php @@ -74,6 +74,20 @@ class HTTPAuth return false; } + /* + * Logs out the administrative user + */ + public function logout(): void + { + session_unset(); // unset all session variables + session_destroy(); // destroy the session + $redirectUrl = $_SERVER['REQUEST_URI']; + if (strpos($redirectUrl, '/login') === false) { + header('Location: /login?action=' . urlencode($redirectUrl)); + exit(); + } + } + /* * Gets the current authentication config * return array $config