Browse Source

oops.

no_SessionID_in_API
Roker 6 years ago
parent
commit
7e16aa6611
3 changed files with 3 additions and 79 deletions
  1. +0
    -5
      html/index.html
  2. +2
    -73
      html/interactive.js
  3. +1
    -1
      server/json_rpc.cc

+ 0
- 5
html/index.html View File

@ -28,11 +28,6 @@
<table class="bigtable" id="bigtable">
<tr><td>Server's Address</td><td> <input type="text" id="server" size="50" maxlength="200" value="http://127.0.0.1:4223/ja/0.1/" </td></tr>
<tr><td></td><td><input type="button" id="crSess" value="Create Session!" onClick="createSession()"></tr></td>
<tr><td>Open sessions:</td>
<td>
<div id="sessions"><i>(none, yet)</i></div>
</td></tr>
<tr><td>Security token:</td>
<td>
<input type="text" id="security_token" size="50" maxlength="80" placeholder="see /tmp/pEp-json-token-*">


+ 2
- 73
html/interactive.js View File

@ -1,6 +1,5 @@
var call_ID = 1000;
var openSessions = [];
var func;
var func_params = [];
@ -62,7 +61,7 @@ var Param2Form =
{
Session : function(nr, pp, value)
{
return getSessions(true);
return '<i>– handled internally –</i>';
},
String : function(nr, pp, value)
{
@ -94,7 +93,6 @@ var Param2Form =
+ '<tr><td>longmsg: </td><td>' + genInput('inp_param_' + nr + '_lmsg', 25, pp.direction, "longmsg") + '</td></tr>'
+ '<tr><td>from: </td><td>' + Param2Form.Identity( nr + '_from', pp.direction, "(from)") + '</td></tr>'
+ '<tr><td>to: </td><td>' + Param2Form.IdentityList( nr + '_to', pp.direction, "(to)") + '</td></tr>'
+ '</table>';
},
Identity : function(nr, pp, value)
@ -141,7 +139,7 @@ var Form2Param =
{
Session : function(nr, pp, value)
{
return $('input[name=sessionRadio]:checked', '#frm').val();
return "[S]";
},
String : function(nr, pp, value)
{
@ -212,73 +210,6 @@ function sprintf(format)
};
function getSessions(with_radio)
{
if(openSessions.length == 0)
{
return '<i>(no open sessions)</i>';
}
var content = '';
var lastSession = openSessions.length - 1;
for(var i=0; i<openSessions.length; ++i)
{
var os = openSessions[i];
content += (with_radio ? '<input type="radio" name="sessionRadio" value="' + os.session + '"' + (i==lastSession ? ' checked' : '') + '>' : '')
+ '&nbsp;<tt>' + os.session + '</tt><br>';
}
return content;
}
function showSessions()
{
document.getElementById("sessions").innerHTML = getSessions(false);
}
function createSession()
{
var url = document.getElementById("server").value + 'createSession';
var request = {};
request.id = ++call_ID;
request.jsonrpc = "2.0";
request.security_token = document.getElementById("security_token").value;
request.method = 'createSession';
request.params = [];
var x = $.post(url, JSON.stringify(request), null, "json")
.done(function(data, status, xhr) {
openSessions.push(data);
showSessions();
})
.fail(function( hdr, txt, err) {
alert( "error [" + hdr + "|" + txt + "|" + err + "]" );
})
;
}
function getAllSessions()
{
var url = document.getElementById("server").value + 'getAllSessions';
var request = {};
request.id = ++call_ID;
request.jsonrpc = "2.0";
request.security_token = document.getElementById("security_token").value;
request.method = 'getAllSessions';
request.params = [];
var x = $.post(url, JSON.stringify(request), null, "json")
.done(function(data, status, xhr) {
openSessions = data;
showSessions();
})
.fail(function( hdr, txt, err) {
alert( "error [" + hdr + "|" + txt + "|" + err + "]" );
})
;
}
function displayResult(response)
{
var pre = document.getElementById("resultpre");
@ -294,7 +225,6 @@ function displayResult(response)
pre.className = "red";
}
getAllSessions(); // to update the session lists
on_select_change(); // to update the function parameters
}
@ -449,5 +379,4 @@ function init_pep_functions()
}
document.getElementById("fn_name").innerHTML = optionList;
document.getElementById("spn_version").innerHTML = "version: " + server_version;
getAllSessions();
}

+ 1
- 1
server/json_rpc.cc View File

@ -57,7 +57,7 @@ js::Object call(const FunctionMap& fm, const js::Object& request, const std::str
}
const auto sec_token = find_value(request, "security_token");
if(sec_token.type()!=js::str_type || (sec_token.get_str()!=sec_token_orig) == false)
if(sec_token.type()!=js::str_type || (sec_token.get_str()!=sec_token_orig) )
{
return make_error(JSON_RPC::INVALID_REQUEST, "Invalid request: Wrong security token.", request, request_id);
}


Loading…
Cancel
Save