diff --git a/app/js/index.js b/app/js/index.js index a6dc9124..219bd5cb 100644 --- a/app/js/index.js +++ b/app/js/index.js @@ -597,8 +597,14 @@ var UI = (function(UI, undefined) { config.lightWalletHost = res[1]; config.lightWalletPort = res[2]; - config.lightWalletUser = document.getElementById("light_wallet_user").value; - config.lightWalletPassword = document.getElementById("light_wallet_password").value; + var lightWalletUser = document.getElementById("light_wallet_user").value; + if (lightWalletUser !== "") { + config.lightWalletUser = lightWalletUser; + } + var lightWalletPassword = document.getElementById("light_wallet_password").value; + if (lightWalletPassword !== "") { + config.lightWalletPassword = lightWalletPassword; + } config.minWeightMagnitude = parseInt(document.getElementById("server_config_min_weight_magnitude").value, 10); } else { diff --git a/app/js/main.js b/app/js/main.js index 4b1d903f..bcb5dca6 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -2080,6 +2080,11 @@ var App = (function(App, undefined) { settings.lightWalletUser = lightWalletUser; lightWalletHostChange = true; } + } else { + if (settings.hasOwnProperty("lightWalletUser")) { + delete settings["lightWalletUser"] + lightWalletHostChange = true; + } } if (configuration.hasOwnProperty("lightWalletPassword")) { @@ -2088,6 +2093,11 @@ var App = (function(App, undefined) { settings.lightWalletPassword = lightWalletPassword; lightWalletHostChange = true; } + } else { + if (settings.hasOwnProperty("lightWalletPassword")) { + delete settings["lightWalletPassword"] + lightWalletHostChange = true; + } } } else { if (configuration.hasOwnProperty("nodes")) { @@ -2176,10 +2186,16 @@ var App = (function(App, undefined) { if (relaunch || !App.windowIsReady()) { App.relaunchApplication(); } else if (lightWalletHostChange && settings.lightWallet == 1) { - win.webContents.send("updateSettings", { + var updatedSettings = { "host": settings.lightWalletHost, "port": settings.lightWalletPort - }); + }; + if(settings.lightWalletUser) { + updatedSettings.lightWalletUser = settings.lightWalletUser; + updatedSettings.lightWalletPassword = settings.lightWalletPassword; + } + + win.webContents.send("updateSettings", updatedSettings); } else { win.webContents.send("updateSettings", { "depth": settings.depth, diff --git a/ui/js/ui.utils.js b/ui/js/ui.utils.js index 4697ade5..38c96293 100644 --- a/ui/js/ui.utils.js +++ b/ui/js/ui.utils.js @@ -238,6 +238,7 @@ var UI = (function(UI, $, undefined) { } var changeNode = false; + var hasAuth = false; if (settings.hasOwnProperty("host") && settings.host != connection.host) { connection.host = settings.host; @@ -248,8 +249,48 @@ var UI = (function(UI, $, undefined) { changeNode = true; } + if (settings.hasOwnProperty("lightWalletUser")) { + hasAuth = true; + + if (settings.lightWalletUser != connection.lightWalletUser) { + connection.lightWalletUser = settings.lightWalletUser; + changeNode = true; + } + } else { + if(connection.hasOwnProperty("lightWalletUser")) { + delete connection["lightWalletUser"] + changeNode = true; + } + } + + if (settings.hasOwnProperty("lightWalletPassword")) { + hasAuth = true; + if (settings.lightWalletPassword != connection.lightWalletPassword) { + connection.lightWalletPassword = settings.lightWalletPassword; + changeNode = true; + } + } else { + if(connection.hasOwnProperty("lightWalletPassword")) { + delete connection["lightWalletPassword"] + changeNode = true; + } + } + if (changeNode) { - iota.changeNode({"host": connection.host, "port": connection.port}); + var nodeSettings = { + "host": connection.host, + "port": connection.port, + }; + + if (hasAuth) { + nodeSettings.auth = { + "type": "basic", + "user": connection.lightWalletUser, + "password": connection.lightWalletPassword + }; + } + + iota.changeNode(nodeSettings); } if (settings.hasOwnProperty("addedNodes") && settings.addedNodes.length) {