mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2026-08-13 12:33:07 +02:00
Add defensive auth guards and cleanup iteration usage
This commit is contained in:
parent
40bd25d921
commit
bd0f515a6e
4 changed files with 52 additions and 46 deletions
|
|
@ -201,17 +201,19 @@ export const updateNodeSettings = (req, res, next) => {
|
|||
const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index));
|
||||
if (node && node.settings) {
|
||||
node.settings = { ...node.settings, ...req.body.settings };
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.swapMacaroonPath;
|
||||
if (node.authentication && req.body.authentication) {
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete node.authentication.swapMacaroonPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
@ -219,17 +221,19 @@ export const updateNodeSettings = (req, res, next) => {
|
|||
const selectedNode = common.findNode(req.session.selectedNode.index);
|
||||
if (selectedNode && selectedNode.settings) {
|
||||
selectedNode.settings = { ...selectedNode.settings, ...req.body.settings };
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
selectedNode.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete selectedNode.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
selectedNode.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete selectedNode.authentication.swapMacaroonPath;
|
||||
if (selectedNode.authentication && req.body.authentication) {
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
selectedNode.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete selectedNode.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
selectedNode.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
}
|
||||
else {
|
||||
delete selectedNode.authentication.swapMacaroonPath;
|
||||
}
|
||||
}
|
||||
common.replaceNode(req, selectedNode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ export class CommonService {
|
|||
delete config.multiPass;
|
||||
delete config.multiPassHashed;
|
||||
delete config.secret2FA;
|
||||
config.nodes?.map((node) => this.removeAuthSecureData(node));
|
||||
config.nodes?.forEach((node) => this.removeAuthSecureData(node));
|
||||
return config;
|
||||
};
|
||||
this.addSecureData = (config) => {
|
||||
|
|
@ -70,7 +70,7 @@ export class CommonService {
|
|||
config.secret2FA = this.appConfig.secret2FA;
|
||||
}
|
||||
const appConfigNodes = new Map(this.appConfig.nodes?.map((node) => [node.index, node]));
|
||||
config.nodes.map((node) => {
|
||||
config.nodes.forEach((node) => {
|
||||
const appConfigNode = appConfigNodes.get(node.index);
|
||||
if (appConfigNode?.authentication) {
|
||||
if (appConfigNode.authentication.macaroonPath) {
|
||||
|
|
@ -83,7 +83,6 @@ export class CommonService {
|
|||
node.authentication.lnApiPassword = appConfigNode.authentication.lnApiPassword;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -205,15 +205,17 @@ export const updateNodeSettings = (req, res, next) => {
|
|||
const node = config.nodes.find((node) => (node.index === req.session.selectedNode.index));
|
||||
if (node && node.settings) {
|
||||
node.settings = { ...node.settings, ...req.body.settings };
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
} else {
|
||||
delete node.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
} else {
|
||||
delete node.authentication.swapMacaroonPath;
|
||||
if (node.authentication && req.body.authentication) {
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
node.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
} else {
|
||||
delete node.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
node.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
} else {
|
||||
delete node.authentication.swapMacaroonPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
@ -221,15 +223,17 @@ export const updateNodeSettings = (req, res, next) => {
|
|||
const selectedNode = common.findNode(req.session.selectedNode.index);
|
||||
if (selectedNode && selectedNode.settings) {
|
||||
selectedNode.settings = { ...selectedNode.settings, ...req.body.settings };
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
selectedNode.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
} else {
|
||||
delete selectedNode.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
selectedNode.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
} else {
|
||||
delete selectedNode.authentication.swapMacaroonPath;
|
||||
if (selectedNode.authentication && req.body.authentication) {
|
||||
if (req.body.authentication.boltzMacaroonPath) {
|
||||
selectedNode.authentication.boltzMacaroonPath = req.body.authentication.boltzMacaroonPath;
|
||||
} else {
|
||||
delete selectedNode.authentication.boltzMacaroonPath;
|
||||
}
|
||||
if (req.body.authentication.swapMacaroonPath) {
|
||||
selectedNode.authentication.swapMacaroonPath = req.body.authentication.swapMacaroonPath;
|
||||
} else {
|
||||
delete selectedNode.authentication.swapMacaroonPath;
|
||||
}
|
||||
}
|
||||
common.replaceNode(req, selectedNode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export class CommonService {
|
|||
delete config.multiPass;
|
||||
delete config.multiPassHashed;
|
||||
delete config.secret2FA;
|
||||
config.nodes?.map((node) => this.removeAuthSecureData(node));
|
||||
config.nodes?.forEach((node) => this.removeAuthSecureData(node));
|
||||
return config;
|
||||
};
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ export class CommonService {
|
|||
config.secret2FA = this.appConfig.secret2FA;
|
||||
}
|
||||
const appConfigNodes = new Map(this.appConfig.nodes?.map((node) => [node.index, node]));
|
||||
config.nodes.map((node) => {
|
||||
config.nodes.forEach((node) => {
|
||||
const appConfigNode = appConfigNodes.get(node.index);
|
||||
if (appConfigNode?.authentication) {
|
||||
if (appConfigNode.authentication.macaroonPath) {
|
||||
|
|
@ -92,7 +92,6 @@ export class CommonService {
|
|||
node.authentication.lnApiPassword = appConfigNode.authentication.lnApiPassword;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue