Add credentials support so token persists in Node-RED UI

This commit is contained in:
2026-10-15 14:43:43 +02:00
parent fd4ace8c13
commit 77aee0f064
+10 -4
View File
@@ -10,9 +10,9 @@ module.exports = function (RED) {
node.baseUrl = (config.baseUrl || "https://example.com/api/v1").replace(/\/+$/, "");
node.useToken = config.useToken !== false;
node.token = config.token || "";
node.username = config.username || "";
node.password = config.password || "";
node.token = (this.credentials && this.credentials.token) || config.token || "";
node.username = (this.credentials && this.credentials.username) || config.username || "";
node.password = (this.credentials && this.credentials.password) || config.password || "";
node.sendRequest = function (method, path, body, msgHeaders, callback) {
const url = new URL(node.baseUrl + path);
@@ -55,5 +55,11 @@ module.exports = function (RED) {
};
}
RED.nodes.registerType("zammad-config", ZammadConfigNode);
RED.nodes.registerType("zammad-config", ZammadConfigNode, {
credentials: {
token: { type: "text" },
username: { type: "text" },
password: { type: "password" }
}
});
};