mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-29 06:23:01 +00:00
41 lines
1.7 KiB
Text
41 lines
1.7 KiB
Text
<?php
|
|
register_module([
|
|
"name" => "Logout",
|
|
"version" => "0.6",
|
|
"author" => "Starbeamrainbowlabs",
|
|
"description" => "Adds an action to let users user out. For security reasons it is wise to add this module since logging in automatically opens a session that is valid for 30 days.",
|
|
"id" => "page-logout",
|
|
"code" => function() {
|
|
|
|
/**
|
|
* @api {post} ?action=logout Logout
|
|
* @apiDescription Logout. Make sure that your bot requests this URL when it is finished - this call not only clears your cookies but also clears the server's session file as well. Note that you can request this when you are already logged out and it will completely wipe your session on the server.
|
|
* @apiName Logout
|
|
* @apiGroup Authorisation
|
|
* @apiPermission Anonymous
|
|
*/
|
|
|
|
/*
|
|
* ██ ██████ ██████ ██████ ██ ██ ████████
|
|
* ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
* ██ ██ ██ ██ ███ ██ ██ ██ ██ ██
|
|
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
* ███████ ██████ ██████ ██████ ██████ ██
|
|
*/
|
|
add_action("logout", function() {
|
|
global $env;
|
|
$env->is_logged_in = false;
|
|
unset($env->user);
|
|
unset($env->pass);
|
|
//clear the session variables
|
|
$_SESSION = [];
|
|
session_destroy();
|
|
|
|
exit(page_renderer::render_main("Logout Successful", "<h1>Logout Successful</h1>
|
|
<p>Logout Successful. You can login again <a href='index.php?action=login'>here</a>.</p>"));
|
|
});
|
|
}
|
|
]);
|
|
|
|
?>
|
|
|