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

Commit

Permalink
Auth settings are used when logging in from initial light-wallet sett…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
bmavity committed Jul 10, 2017
1 parent bc9c8da commit e32fa2a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
30 changes: 28 additions & 2 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,8 @@ var App = (function(App, undefined) {
"showStatus": settings.showStatusBar,
"host": (settings.lightWallet == 1 ? settings.lightWalletHost : "http://localhost"),
"port": (settings.lightWallet == 1 ? settings.lightWalletPort : settings.port),
"auth_user": (settings.lightWallet == 1 ? settings.lightWalletUser : null),
"auth_password": (settings.lightWallet == 1 ? settings.lightWalletPassword : null),
"depth": settings.depth,
"minWeightMagnitude": settings.minWeightMagnitude,
"ccurlPath": ccurlPath,
Expand Down Expand Up @@ -2017,8 +2019,16 @@ var App = (function(App, undefined) {
walletType = settings.lightWallet;
}
if (walletType == 1) {
var config = {"lightWallet": 1, "lightWalletHost": settings.lightWalletHost, "lightWalletPort": settings.lightWalletPort, "minWeightMagnitude": settings.minWeightMagnitude, "testNet": isTestNet, "minWeightMagnitudeMinimum": minWeightMagnitudeMinimum};

var config = {
"lightWallet": 1,
"lightWalletHost": settings.lightWalletHost,
"lightWalletPassword": settings.lightWalletPassword,
"lightWalletPort": settings.lightWalletPort,
"lightWalletUser": settings.lightWalletUser,
"minWeightMagnitude": settings.minWeightMagnitude,
"testNet": isTestNet,
"minWeightMagnitudeMinimum": minWeightMagnitudeMinimum
};
var req = https.get('https://iotasupport.com/providers.json?' + (new Date().getTime()));
req.on('response', function (res) {
var body = '';
Expand Down Expand Up @@ -2108,6 +2118,22 @@ var App = (function(App, undefined) {
lightWalletHostChange = true;
}
}

if (configuration.hasOwnProperty("lightWalletUser")) {
var lightWalletUser = configuration.lightWalletUser;
if (lightWalletUser != settings.lightWalletUser) {
settings.lightWalletUser = lightWalletUser;
lightWalletHostChange = true;
}
}

if (configuration.hasOwnProperty("lightWalletPassword")) {
var lightWalletPassword = configuration.lightWalletPassword;
if (lightWalletPassword != settings.lightWalletPassword) {
settings.lightWalletPassword = lightWalletPassword;
lightWalletHostChange = true;
}
}
} else {
if (configuration.hasOwnProperty("nodes")) {
var nodes = [];
Expand Down
2 changes: 2 additions & 0 deletions app/windows/js/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ var UI = (function(UI, undefined) {
settings.lightWallet = 1;
settings.lightWalletHost = res[1];
settings.lightWalletPort = res[2];
settings.lightWalletUser = document.getElementById("light_wallet_user").value;
settings.lightWalletPassword = document.getElementById("light_wallet_password").value;
}
}

Expand Down
21 changes: 17 additions & 4 deletions ui/js/ui.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ var UI = (function(UI, $, undefined) {
if (params.has("interrupt")) {
interruptAttachingToTangle = true;
}

if (params.has("auth_user")) {
connection.auth = {
"type": "basic",
"user": params.get("auth_user"),
"password": params.get("auth_password")
};
}
}

UI.makeMultilingual(connection.language, function() {
Expand All @@ -98,10 +106,15 @@ var UI = (function(UI, $, undefined) {
return;
}

iota = new IOTA({
"host": connection.host,
"port": connection.port
});
var connectionSettings = {
"host": connection.host,
"port": connection.port
};
if (connection.auth) {
connectionSettings.auth = connection.auth;
}

iota = new IOTA(connectionSettings);

if (connection.host != "http://localhost") {
connection.lightWallet = true;
Expand Down

0 comments on commit e32fa2a

Please sign in to comment.