blash/commands/logout.js

62 lines
1.1 KiB
JavaScript
Raw Normal View History

2010-12-25 23:17:30 +01:00
{
"name" : "logout",
"info" : {
"syntax" : "logout",
"brief" : "End the current user session",
},
"action" : function ( arg )
{
var out = '';
if ( !shell.has_users )
{
return "Users module not enabled<br/>\n";
}
2010-12-25 23:17:30 +01:00
if ( shell.user == shell.json.user )
{
return out;
}
shell.user = shell.json.user;
document.cookie = '';
2010-12-26 18:08:43 +01:00
2022-10-17 01:12:44 +02:00
var users_php = './modules/users/users.php';
2010-12-26 18:08:43 +01:00
params = 'action=logout';
var http = new XMLHttpRequest();
http.open ( "POST", users_php, true );
http.setRequestHeader( "Content-type", "application/x-www-form-urlencoded" );
http.onreadystatechange = function ()
{
if ( http.readyState == 4 && http.status == 200 )
{
2011-01-11 12:18:45 +01:00
shell.refreshFiles();
}
}
2010-12-26 18:08:43 +01:00
http.send ( params );
2010-12-31 03:00:35 +01:00
shell.path = shell.json.basepath;
2011-01-07 11:42:38 +01:00
2022-10-17 01:12:44 +02:00
var json_config = './system/config.js';
2011-01-07 11:42:38 +01:00
var http2 = new XMLHttpRequest();
http2.open ( "GET", json_config, true );
http2.onreadystatechange = function ()
{
if ( http2.readyState == 4 && http2.status == 200 )
{
shell.json = eval ( '(' + http2.responseText + ')' );
}
}
http2.send ( null );
2010-12-25 23:17:30 +01:00
return out;
},
}