2020-09-23 22:22:39 +00:00
< ? php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at https :// mozilla . org / MPL / 2.0 /. */
2015-09-19 09:19:56 +00:00
register_module ([
" name " => " Logout " ,
2018-05-11 10:34:57 +00:00
" version " => " 0.6.1 " ,
2015-09-19 09:19:56 +00:00
" 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 () {
2016-06-15 18:20:03 +00:00
/**
* @ 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
*/
2015-12-26 12:55:19 +00:00
/*
* ██ ██████ ██████ ██████ ██ ██ ████████
* ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ██ ██ ██ ███ ██ ██ ██ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ███████ ██████ ██████ ██████ ██████ ██
*/
2015-09-19 09:19:56 +00:00
add_action ( " logout " , function () {
2015-09-22 13:34:18 +00:00
global $env ;
$env -> is_logged_in = false ;
unset ( $env -> user );
2018-05-11 10:34:57 +00:00
unset ( $env -> user_data );
2015-09-19 09:19:56 +00:00
//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 > " ));
});
}
]);
?>