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

Commit b722abb

Browse files
committed
Changing light wallet authentication now works properly
1 parent 35c944d commit b722abb

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
@@ -2116,6 +2116,11 @@ var App = (function(App, undefined) {
21162116
settings.lightWalletUser = lightWalletUser;
21172117
lightWalletHostChange = true;
21182118
}
2119+
} else {
2120+
if (settings.hasOwnProperty("lightWalletUser")) {
2121+
delete settings["lightWalletUser"]
2122+
lightWalletHostChange = true;
2123+
}
21192124
}
21202125

21212126
if (configuration.hasOwnProperty("lightWalletPassword")) {
@@ -2124,6 +2129,11 @@ var App = (function(App, undefined) {
21242129
settings.lightWalletPassword = lightWalletPassword;
21252130
lightWalletHostChange = true;
21262131
}
2132+
} else {
2133+
if (settings.hasOwnProperty("lightWalletPassword")) {
2134+
delete settings["lightWalletPassword"]
2135+
lightWalletHostChange = true;
2136+
}
21272137
}
21282138
} else {
21292139
if (configuration.hasOwnProperty("nodes")) {
@@ -2212,10 +2222,16 @@ var App = (function(App, undefined) {
22122222
if (relaunch || !App.windowIsReady()) {
22132223
App.relaunchApplication();
22142224
} else if (lightWalletHostChange && settings.lightWallet == 1) {
2215-
win.webContents.send("updateSettings", {
2225+
var updatedSettings = {
22162226
"host": settings.lightWalletHost,
22172227
"port": settings.lightWalletPort
2218-
});
2228+
};
2229+
if(settings.lightWalletUser) {
2230+
updatedSettings.lightWalletUser = settings.lightWalletUser;
2231+
updatedSettings.lightWalletPassword = settings.lightWalletPassword;
2232+
}
2233+
2234+
win.webContents.send("updateSettings", updatedSettings);
22192235
} else {
22202236
win.webContents.send("updateSettings", {
22212237
"depth": settings.depth,

ui/js/ui.utils.js

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

249249
var changeNode = false;
250+
var hasAuth = false;
250251

251252
if (settings.hasOwnProperty("host") && settings.host != connection.host) {
252253
connection.host = settings.host;
@@ -257,8 +258,48 @@ var UI = (function(UI, $, undefined) {
257258
changeNode = true;
258259
}
259260

261+
if (settings.hasOwnProperty("lightWalletUser")) {
262+
hasAuth = true;
263+
264+
if (settings.lightWalletUser != connection.lightWalletUser) {
265+
connection.lightWalletUser = settings.lightWalletUser;
266+
changeNode = true;
267+
}
268+
} else {
269+
if(connection.hasOwnProperty("lightWalletUser")) {
270+
delete connection["lightWalletUser"]
271+
changeNode = true;
272+
}
273+
}
274+
275+
if (settings.hasOwnProperty("lightWalletPassword")) {
276+
hasAuth = true;
277+
if (settings.lightWalletPassword != connection.lightWalletPassword) {
278+
connection.lightWalletPassword = settings.lightWalletPassword;
279+
changeNode = true;
280+
}
281+
} else {
282+
if(connection.hasOwnProperty("lightWalletPassword")) {
283+
delete connection["lightWalletPassword"]
284+
changeNode = true;
285+
}
286+
}
287+
260288
if (changeNode) {
261-
iota.changeNode({"host": connection.host, "port": connection.port});
289+
var nodeSettings = {
290+
"host": connection.host,
291+
"port": connection.port,
292+
};
293+
294+
if (hasAuth) {
295+
nodeSettings.auth = {
296+
"type": "basic",
297+
"user": connection.lightWalletUser,
298+
"password": connection.lightWalletPassword
299+
};
300+
}
301+
302+
iota.changeNode(nodeSettings);
262303
}
263304

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

0 commit comments

Comments
 (0)