diff --git a/hardware/Pibrella/38-rpi-pibrella.js b/hardware/Pibrella/38-rpi-pibrella.js
index bba42c38..a5a50893 100644
--- a/hardware/Pibrella/38-rpi-pibrella.js
+++ b/hardware/Pibrella/38-rpi-pibrella.js
@@ -231,7 +231,7 @@ module.exports = function(RED) {
}
RED.nodes.registerType("rpi-pibrella out",PibrellaOut);
- RED.httpAdmin.get('/rpi-pibpins/:id',function(req,res) {
- res.send( JSON.stringify(pinsInUse) );
+ RED.httpAdmin.get('/rpi-pibpins/:id',RED.auth.needsPermission('rpi-pibrella.read'),function(req,res) {
+ res.json(pinsInUse);
});
}
diff --git a/hardware/Pibrella/package.json b/hardware/Pibrella/package.json
index dec44bf4..540c12a4 100644
--- a/hardware/Pibrella/package.json
+++ b/hardware/Pibrella/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-pibrella",
- "version" : "0.0.5",
+ "version" : "0.0.6",
"description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board",
"dependencies" : {
},
diff --git a/hardware/blinkstick/76-blinkstick.js b/hardware/blinkstick/76-blinkstick.js
index 54c1485e..dbc7e67b 100644
--- a/hardware/blinkstick/76-blinkstick.js
+++ b/hardware/blinkstick/76-blinkstick.js
@@ -248,11 +248,9 @@ module.exports = function(RED) {
RED.nodes.registerType("blinkstick",BlinkStick);
- RED.httpAdmin.get("/blinksticklist",function(req,res) {
+ RED.httpAdmin.get("/blinksticklist", RED.auth.needsPermission("blinkstick.read"), function(req,res) {
blinkstick.findAllSerials(function(serials) {
- res.writeHead(200, {'Content-Type': 'application/json'});
- res.write(JSON.stringify(serials));
- res.end();
+ res.json(serials);
});
});
};
diff --git a/hardware/blinkstick/package.json b/hardware/blinkstick/package.json
index 7bc2b1ad..d06f9585 100644
--- a/hardware/blinkstick/package.json
+++ b/hardware/blinkstick/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-blinkstick",
- "version" : "0.1.1",
+ "version" : "0.1.2",
"description" : "A Node-RED node to control a Blinkstick",
"dependencies" : {
"blinkstick" : "1.1.*"
diff --git a/io/emoncms/88-emoncms.html b/io/emoncms/88-emoncms.html
index 4d41deea..9bdd5330 100644
--- a/io/emoncms/88-emoncms.html
+++ b/io/emoncms/88-emoncms.html
@@ -82,33 +82,11 @@
server: {value:"http://localhost",required:true},
name: {value:""}
},
+ credentials: {
+ apikey: {type:"text"}
+ },
label: function() {
return this.name||this.server;
- },
- oneditprepare: function() {
- $.getJSON('emoncms-server/'+this.id,function(data) {
- if (data.apikey) {
- $('#node-config-input-apikey').val(data.apikey);
- }
- });
- },
- oneditsave: function() {
- var newApikey = $('#node-config-input-apikey').val();
- var credentials = {};
- credentials.apikey = newApikey;
- $.ajax({
- url: 'emoncms-server/'+this.id,
- type: 'POST',
- data: credentials,
- success:function(result){}
- });
- },
- ondelete: function() {
- $.ajax({
- url: 'emoncms-server/'+this.id,
- type: 'DELETE',
- success: function(result) {}
- });
}
});
diff --git a/io/emoncms/88-emoncms.js b/io/emoncms/88-emoncms.js
index 9c72fb18..a2904a37 100644
--- a/io/emoncms/88-emoncms.js
+++ b/io/emoncms/88-emoncms.js
@@ -20,56 +20,20 @@ function EmoncmsServerNode(n) {
RED.nodes.createNode(this,n);
this.server = n.server;
this.name = n.name;
- var credentials = RED.nodes.getCredentials(n.id);
- if (credentials) {
- this.apikey = credentials.apikey;
- }
-
}
-RED.nodes.registerType("emoncms-server",EmoncmsServerNode);
-
-var querystring = require('querystring');
-
-RED.httpAdmin.get('/emoncms-server/:id',function(req,res) {
- var credentials = RED.nodes.getCredentials(req.params.id);
- if (credentials) {
- res.send(JSON.stringify({apikey:credentials.apikey}));
- } else {
- res.send(JSON.stringify({}));
+RED.nodes.registerType("emoncms-server",EmoncmsServerNode,{
+ credentials: {
+ apikey: {type:"text"}
}
});
-RED.httpAdmin.delete('/emoncms-server/:id',function(req,res) {
- RED.nodes.deleteCredentials(req.params.id);
- res.send(200);
-});
-
-RED.httpAdmin.post('/emoncms-server/:id',function(req,res) {
-
- var body = "";
- req.on('data', function(chunk) {
- body+=chunk;
- });
- req.on('end', function(){
- var newCreds = querystring.parse(body);
- var credentials = RED.nodes.getCredentials(req.params.id)||{};
- if (newCreds.apikey == null || newCreds.apikey == "") {
- delete credentials.apikey;
- } else {
- credentials.apikey = newCreds.apikey;
- }
- RED.nodes.addCredentials(req.params.id,credentials);
- res.send(200);
- });
-});
-
function Emoncms(n) {
RED.nodes.createNode(this,n);
this.emonServer = n.emonServer;
var sc = RED.nodes.getNode(this.emonServer);
this.baseurl = sc.server;
- this.apikey = sc.apikey;
+ this.apikey = sc.credentials.apikey;
this.nodegroup = n.nodegroup || "";
var node = this;
diff --git a/io/emoncms/package.json b/io/emoncms/package.json
index 76638db9..7c6dd87a 100644
--- a/io/emoncms/package.json
+++ b/io/emoncms/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-emoncms",
- "version" : "0.0.1",
+ "version" : "0.0.2",
"description" : "A Node-RED node to send energy data to emoncms.org.",
"dependencies" : {
},
diff --git a/io/stomp/18-stomp.html b/io/stomp/18-stomp.html
index 8a99a143..6591bf3c 100644
--- a/io/stomp/18-stomp.html
+++ b/io/stomp/18-stomp.html
@@ -110,7 +110,7 @@
-
+
@@ -126,44 +126,12 @@
port: {value:61618,required:true,validate:RED.validators.number()},
name: {}
},
+ credentials: {
+ user: {type:"text"},
+ password: {type: "password"}
+ },
label: function() {
return (this.name?this.name:this.server+":"+this.port);
- },
- oneditprepare: function() {
- $.getJSON('stomp-server/'+this.id,function(data) {
- if (data.user) {
- $('#node-config-input-user').val(data.user);
- }
- if (data.hasPassword) {
- $('#node-config-input-pass').val('__PWRD__');
- } else {
- $('#node-config-input-pass').val('');
- }
- if (data.global) $('#node-config-cred-tip').show();
- else $('#node-config-cred-tip').hide();
- });
- },
- oneditsave: function() {
- var credentials = {};
- var newUser = $('#node-config-input-user').val();
- var newPass = $('#node-config-input-pass').val();
- credentials.user = newUser;
- if (newPass != '__PWRD__') {
- credentials.password = newPass;
- }
- $.ajax({
- url: 'stomp-server/'+this.id,
- type: 'POST',
- data: credentials,
- success: function(result){}
- });
- },
- ondelete: function() {
- $.ajax({
- url: 'stomp-server/'+this.id,
- type: 'DELETE',
- success: function(result) {}
- });
}
});
diff --git a/io/stomp/18-stomp.js b/io/stomp/18-stomp.js
index 6f9ce3ff..982fb6d7 100644
--- a/io/stomp/18-stomp.js
+++ b/io/stomp/18-stomp.js
@@ -24,52 +24,16 @@ module.exports = function(RED) {
this.server = n.server;
this.port = n.port;
this.name = n.name;
- var credentials = RED.nodes.getCredentials(n.id);
- if (credentials) {
- this.username = credentials.user;
- this.password = credentials.password;
- }
+ this.username = this.credentials.user;
+ this.password = this.credentials.password;
}
- RED.nodes.registerType("stomp-server",StompServerNode);
-
- RED.httpAdmin.get('/stomp-server/:id',function(req,res) {
- var credentials = RED.nodes.getCredentials(req.params.id);
- if (credentials) {
- res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!=="")}));
- } else {
- res.send(JSON.stringify({}));
+ RED.nodes.registerType("stomp-server",StompServerNode,{
+ credentials: {
+ user: {type:"text"},
+ password: {type: "password"}
}
});
- RED.httpAdmin.delete('/stomp-server/:id',function(req,res) {
- RED.nodes.deleteCredentials(req.params.id);
- res.send(200);
- });
-
- RED.httpAdmin.post('/stomp-server/:id',function(req,res) {
- var body = "";
- req.on('data', function(chunk) {
- body+=chunk;
- });
- req.on('end', function(){
- var newCreds = querystring.parse(body);
- var credentials = RED.nodes.getCredentials(req.params.id)||{};
- if (newCreds.user == null || newCreds.user === "") {
- delete credentials.user;
- } else {
- credentials.user = newCreds.user;
- }
- if (newCreds.password === "") {
- delete credentials.password;
- } else {
- credentials.password = newCreds.password||credentials.password;
- }
- RED.nodes.addCredentials(req.params.id,credentials);
- res.send(200);
- });
- });
-
-
function StompInNode(n) {
RED.nodes.createNode(this,n);
this.server = n.server;
diff --git a/io/stomp/package.json b/io/stomp/package.json
index 7eec8101..b4eb4a73 100644
--- a/io/stomp/package.json
+++ b/io/stomp/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-stomp",
- "version" : "0.0.1",
+ "version" : "0.0.2",
"description" : "A Node-RED node to publish and subscribe to/from a Stomp server",
"dependencies" : {
"stomp-client" : "0.5.0"
diff --git a/social/nma/57-nma.html b/social/nma/57-nma.html
index 72efa216..6253d724 100644
--- a/social/nma/57-nma.html
+++ b/social/nma/57-nma.html
@@ -44,6 +44,9 @@
title: {value:""},
name: {value:""}
},
+ credentials: {
+ pushkey: {type: "password"}
+ },
color:"#a7c9a0",
inputs:1,
outputs:0,
@@ -54,35 +57,6 @@
},
labelStyle: function() {
return this.name?"node_label_italic":"";
- },
- oneditprepare: function() {
- $.getJSON('nma/'+this.id,function(data) {
- if (data.hasPassword) {
- $('#node-config-input-pushkey').val('__PWRD__');
- } else {
- $('#node-config-input-pushkey').val('');
- }
- });
- },
- oneditsave: function() {
- var credentials = {};
- var newPass = $('#node-config-input-pushkey').val();
- if (newPass != '__PWRD__') {
- credentials.pushkey = newPass;
- $.ajax({
- url: 'nma/'+this.id,
- type: 'POST',
- data: credentials,
- success: function(result){}
- });
- }
- },
- ondelete: function() {
- $.ajax({
- url: 'nma/'+this.id,
- type: 'DELETE',
- success: function(result) {}
- });
}
});
diff --git a/social/nma/57-nma.js b/social/nma/57-nma.js
index 3870a05b..ad431702 100644
--- a/social/nma/57-nma.js
+++ b/social/nma/57-nma.js
@@ -21,7 +21,7 @@ module.exports = function(RED) {
function NMANode(n) {
RED.nodes.createNode(this,n);
this.title = n.title;
- var credentials = RED.nodes.getCredentials(n.id);
+ var credentials = this.credentials;
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
else { this.error("No NMA API key set"); }
var node = this;
@@ -50,39 +50,9 @@ module.exports = function(RED) {
});
}
- RED.nodes.registerType("nma",NMANode);
-
- var querystring = require('querystring');
-
- RED.httpAdmin.get('/nma/:id',function(req,res) {
- var credentials = RED.nodes.getCredentials(req.params.id);
- if (credentials) {
- res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
- } else {
- res.send(JSON.stringify({}));
+ RED.nodes.registerType("nma",NMANode, {
+ credentials: {
+ pushkey: {type: "password"}
}
});
-
- RED.httpAdmin.delete('/nma/:id',function(req,res) {
- RED.nodes.deleteCredentials(req.params.id);
- res.send(200);
- });
-
- RED.httpAdmin.post('/nma/:id',function(req,res) {
- var body = "";
- req.on('data', function(chunk) {
- body+=chunk;
- });
- req.on('end', function(){
- var newCreds = querystring.parse(body);
- var credentials = RED.nodes.getCredentials(req.params.id)||{};
- if (newCreds.pushkey === "") {
- delete credentials.pushkey;
- } else {
- credentials.pushkey = newCreds.pushkey||credentials.pushkey;
- }
- RED.nodes.addCredentials(req.params.id,credentials);
- res.send(200);
- });
- });
}
diff --git a/social/nma/package.json b/social/nma/package.json
index 07932d16..a7a73726 100644
--- a/social/nma/package.json
+++ b/social/nma/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-nma",
- "version" : "0.0.2",
+ "version" : "0.0.3",
"description" : "A Node-RED node to send alerts via Notify-My-Android",
"dependencies" : {
"nma" : "0.2.2"
diff --git a/social/prowl/57-prowl.html b/social/prowl/57-prowl.html
index bc90e6df..95fda682 100644
--- a/social/prowl/57-prowl.html
+++ b/social/prowl/57-prowl.html
@@ -32,7 +32,6 @@
- Note: Using credentials from global pushkey.js file.
diff --git a/social/prowl/57-prowl.js b/social/prowl/57-prowl.js
index a0f42f6e..5d48d37a 100644
--- a/social/prowl/57-prowl.js
+++ b/social/prowl/57-prowl.js
@@ -18,11 +18,6 @@ module.exports = function(RED) {
"use strict";
var Prowl = require('node-prowl');
- // Either add a line like this to settings.js
- // prowl: {prowlkey:'My-API-KEY'},
- // or create pushkey.js in dir ABOVE node-red, it just needs to be like
- // module.exports = {prowlkey:'My-API-KEY'}
-
try {
var pushkeys = RED.settings.prowl || require(process.env.NODE_RED_HOME+"/../pushkey.js");
}
@@ -34,7 +29,7 @@ module.exports = function(RED) {
this.priority = parseInt(n.priority);
if (this.priority > 2) { this.priority = 2; }
if (this.priority < -2) { this.priority = -2; }
- var credentials = RED.nodes.getCredentials(n.id);
+ var credentials = this.credentials;
if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; }
else {
if (pushkeys) { this.pushkey = pushkeys.prowlkey; }
@@ -67,45 +62,9 @@ module.exports = function(RED) {
}
});
}
- RED.nodes.registerType("prowl",ProwlNode);
-
- var querystring = require('querystring');
-
- RED.httpAdmin.get('/prowl/:id',function(req,res) {
- var credentials = RED.nodes.getCredentials(req.params.id);
- if (credentials) {
- res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")}));
+ RED.nodes.registerType("prowl",ProwlNode,{
+ credentials: {
+ pushkey: {type: "password"}
}
- else if (pushkeys && pushkeys.prowlkey) {
- RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.prowlkey,global:true});
- credentials = RED.nodes.getCredentials(req.params.id);
- res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!==""),global:credentials.global}));
- }
- else {
- res.send(JSON.stringify({}));
- }
- });
-
- RED.httpAdmin.delete('/prowl/:id',function(req,res) {
- RED.nodes.deleteCredentials(req.params.id);
- res.send(200);
- });
-
- RED.httpAdmin.post('/prowl/:id',function(req,res) {
- var body = "";
- req.on('data', function(chunk) {
- body+=chunk;
- });
- req.on('end', function(){
- var newCreds = querystring.parse(body);
- var credentials = RED.nodes.getCredentials(req.params.id)||{};
- if (newCreds.pushkey === "") {
- delete credentials.pushkey;
- } else {
- credentials.pushkey = newCreds.pushkey||credentials.pushkey;
- }
- RED.nodes.addCredentials(req.params.id,credentials);
- res.send(200);
- });
});
}
diff --git a/social/prowl/package.json b/social/prowl/package.json
index 5df611e1..80a6c0cd 100644
--- a/social/prowl/package.json
+++ b/social/prowl/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-prowl",
- "version" : "0.0.1",
+ "version" : "0.0.2",
"description" : "A Node-RED node to send alerts via Prowl",
"dependencies" : {
"node-prowl" : "0.1.7"
diff --git a/social/pusher/114-pusher.html b/social/pusher/114-pusher.html
index 086a681d..94241dae 100644
--- a/social/pusher/114-pusher.html
+++ b/social/pusher/114-pusher.html
@@ -1,6 +1,6 @@