diff --git a/webui-src/app/downloads.js b/webui-src/app/downloads.js index 946b670..709d958 100644 --- a/webui-src/app/downloads.js +++ b/webui-src/app/downloads.js @@ -43,8 +43,8 @@ function cntrlBtn(file, act) { } module.exports = { - //oninit: rs.Downloads.load(), // means we re-load the list everytime we render - //onload: rs.Downloads.load(), // means we re-load the list everytime we render + oninit: rs.Downloads.load(), // means we re-load the list everytime we render + onload: rs.Downloads.load(), // means we re-load the list everytime we render view: function() { var filestreamer_url = "/fstream/"; diff --git a/webui-src/app/login.js b/webui-src/app/login.js index a58af9f..081f326 100644 --- a/webui-src/app/login.js +++ b/webui-src/app/login.js @@ -3,7 +3,7 @@ var rs = require("rswebui"); function loginResponse(isSuccessful) { if (isSuccessful) { - window.location.href = window.location.href.split("?")[0] + "?/downloads"; + m.route.set("/downloads"); } else { m.render(document.getElementById("warning"), "Incorrent login/password"); diff --git a/webui-src/app/rswebui.js b/webui-src/app/rswebui.js index a9ae01a..0cd10a9 100644 --- a/webui-src/app/rswebui.js +++ b/webui-src/app/rswebui.js @@ -6,10 +6,13 @@ var rsJsonApiUrl = "http://127.0.0.1:9092" var loginKey = { username: "", passwd: "", + isSuccessful: false, }; function rsJsonApiRequest(path, data, callback, async, failCallback) { + if(loginKey.isSuccessful) + { console.log("rsJsonApiRequest(path, data, callback)", path, data, callback) var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() @@ -29,21 +32,29 @@ function rsJsonApiRequest(path, data, callback, async, failCallback) xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Authorization", "Basic "+btoa(loginKey.username + ":" + loginKey.passwd)); xhr.send(data); + } } function validateLogin(username, password, callback) { - loginKey.username = username; - loginKey.passwd = password; - rsJsonApiRequest("/rsPeers/GetRetroshareInvite", - "", - function() { - callback(true); - }, - true, - function() { - callback(false); - }, - ) + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function() { + if(xhr.readyState === 4) { + + if(xhr.status === 200) { + callback(true); + loginKey.username = username; + loginKey.passwd = password; + loginKey.isSuccessful = true; + } + else + callback(false); + + } + } + xhr.open('POST', rsJsonApiUrl + "/rsPeers/GetRetroshareInvite", true); + xhr.setRequestHeader("Accept", "application/json"); + xhr.setRequestHeader("Authorization", "Basic "+btoa(username + ":" + password)); + xhr.send(""); } // These constants are the onces listed in retroshare/rsfiles.h. I would like to make them "members" of Downloads