Add credentials support so key/secret persist in Node-RED UI
This commit is contained in:
@@ -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" }
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user