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

Commit

Permalink
Changing light wallet authentication now works properly
Browse files Browse the repository at this point in the history
  • Loading branch information
bmavity committed Jun 23, 2017
1 parent 6da984a commit cc0b02e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
10 changes: 8 additions & 2 deletions app/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 18 additions & 2 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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")) {
Expand Down Expand Up @@ -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,
Expand Down
43 changes: 42 additions & 1 deletion ui/js/ui.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit cc0b02e

Please sign in to comment.