Add credentials support so token persists in Node-RED UI
This commit is contained in:
+10
-4
@@ -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" }
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user