Add credentials support so key/secret persist in Node-RED UI

This commit is contained in:
2026-10-15 14:43:44 +02:00
parent 294c3f8ab9
commit 659f7d603d
+8 -3
View File
@@ -9,8 +9,8 @@ module.exports = function (RED) {
const node = this; const node = this;
node.baseUrl = (config.baseUrl || "https://example.com/wp-json/wc/v3").replace(/\/+$/, ""); node.baseUrl = (config.baseUrl || "https://example.com/wp-json/wc/v3").replace(/\/+$/, "");
node.consumerKey = config.consumerKey || ""; node.consumerKey = (this.credentials && this.credentials.consumerKey) || config.consumerKey || "";
node.consumerSecret = config.consumerSecret || ""; node.consumerSecret = (this.credentials && this.credentials.consumerSecret) || config.consumerSecret || "";
node.sendRequest = function (method, path, body, msgHeaders, callback) { node.sendRequest = function (method, path, body, msgHeaders, callback) {
const url = new URL(node.baseUrl + path); const url = new URL(node.baseUrl + path);
@@ -48,5 +48,10 @@ module.exports = function (RED) {
}; };
} }
RED.nodes.registerType("woocommerce-config", WooCommerceConfigNode); RED.nodes.registerType("woocommerce-config", WooCommerceConfigNode, {
credentials: {
consumerKey: { type: "text" },
consumerSecret: { type: "password" }
}
});
}; };