Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit cc0b02e

Browse files
committed
Changing light wallet authentication now works properly
1 parent 6da984a commit cc0b02e

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

app/js/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,14 @@ var UI = (function(UI, undefined) {
597597
config.lightWalletHost = res[1];
598598
config.lightWalletPort = res[2];
599599

600-
config.lightWalletUser = document.getElementById("light_wallet_user").value;
601-
config.lightWalletPassword = document.getElementById("light_wallet_password").value;
600+
var lightWalletUser = document.getElementById("light_wallet_user").value;
601+
if (lightWalletUser !== "") {
602+
config.lightWalletUser = lightWalletUser;
603+
}
604+
var lightWalletPassword = document.getElementById("light_wallet_password").value;
605+
if (lightWalletPassword !== "") {
606+
config.lightWalletPassword = lightWalletPassword;
607+
}
602608

603609
config.minWeightMagnitude = parseInt(document.getElementById("server_config_min_weight_magnitude").value, 10);
604610
} else {

app/js/main.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,11 @@ var App = (function(App, undefined) {
20802080
settings.lightWalletUser = lightWalletUser;
20812081
lightWalletHostChange = true;
20822082
}
2083+
} else {
2084+
if (settings.hasOwnProperty("lightWalletUser")) {
2085+
delete settings["lightWalletUser"]
2086+
lightWalletHostChange = true;
2087+
}
20832088
}
20842089

20852090
if (configuration.hasOwnProperty("lightWalletPassword")) {
@@ -2088,6 +2093,11 @@ var App = (function(App, undefined) {
20882093
settings.lightWalletPassword = lightWalletPassword;
20892094
lightWalletHostChange = true;
20902095
}
2096+
} else {
2097+
if (settings.hasOwnProperty("lightWalletPassword")) {
2098+
delete settings["lightWalletPassword"]
2099+
lightWalletHostChange = true;
2100+
}
20912101
}
20922102
} else {
20932103
if (configuration.hasOwnProperty("nodes")) {
@@ -2176,10 +2186,16 @@ var App = (function(App, undefined) {
21762186
if (relaunch || !App.windowIsReady()) {
21772187
App.relaunchApplication();
21782188
} else if (lightWalletHostChange && settings.lightWallet == 1) {
2179-
win.webContents.send("updateSettings", {
2189+
var updatedSettings = {
21802190
"host": settings.lightWalletHost,
21812191
"port": settings.lightWalletPort
2182-
});
2192+
};
2193+
if(settings.lightWalletUser) {
2194+
updatedSettings.lightWalletUser = settings.lightWalletUser;
2195+
updatedSettings.lightWalletPassword = settings.lightWalletPassword;
2196+
}
2197+
2198+
win.webContents.send("updateSettings", updatedSettings);
21832199
} else {
21842200
win.webContents.send("updateSettings", {
21852201
"depth": settings.depth,

ui/js/ui.utils.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ var UI = (function(UI, $, undefined) {
238238
}
239239

240240
var changeNode = false;
241+
var hasAuth = false;
241242

242243
if (settings.hasOwnProperty("host") && settings.host != connection.host) {
243244
connection.host = settings.host;
@@ -248,8 +249,48 @@ var UI = (function(UI, $, undefined) {
248249
changeNode = true;
249250
}
250251

252+
if (settings.hasOwnProperty("lightWalletUser")) {
253+
hasAuth = true;
254+
255+
if (settings.lightWalletUser != connection.lightWalletUser) {
256+
connection.lightWalletUser = settings.lightWalletUser;
257+
changeNode = true;
258+
}
259+
} else {
260+
if(connection.hasOwnProperty("lightWalletUser")) {
261+
delete connection["lightWalletUser"]
262+
changeNode = true;
263+
}
264+
}
265+
266+
if (settings.hasOwnProperty("lightWalletPassword")) {
267+
hasAuth = true;
268+
if (settings.lightWalletPassword != connection.lightWalletPassword) {
269+
connection.lightWalletPassword = settings.lightWalletPassword;
270+
changeNode = true;
271+
}
272+
} else {
273+
if(connection.hasOwnProperty("lightWalletPassword")) {
274+
delete connection["lightWalletPassword"]
275+
changeNode = true;
276+
}
277+
}
278+
251279
if (changeNode) {
252-
iota.changeNode({"host": connection.host, "port": connection.port});
280+
var nodeSettings = {
281+
"host": connection.host,
282+
"port": connection.port,
283+
};
284+
285+
if (hasAuth) {
286+
nodeSettings.auth = {
287+
"type": "basic",
288+
"user": connection.lightWalletUser,
289+
"password": connection.lightWalletPassword
290+
};
291+
}
292+
293+
iota.changeNode(nodeSettings);
253294
}
254295

255296
if (settings.hasOwnProperty("addedNodes") && settings.addedNodes.length) {

0 commit comments

Comments
 (0)