Skip to content

Commit cc3bc65

Browse files
committed
update credential access for node-red v0.10
1 parent a75b35b commit cc3bc65

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

77-cloudant-cf.js

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,23 @@ module.exports = function(RED) {
6565
});
6666

6767
RED.httpAdmin.post('/cloudant/:id', function(req,res) {
68-
var body = "";
68+
var newCreds = req.body;
69+
var credentials = RED.nodes.getCredentials(req.params.id) || {};
6970

70-
req.on('data', function(chunk) {
71-
body += chunk;
72-
});
73-
74-
req.on('end', function() {
75-
var newCreds = querystring.parse(body);
76-
var credentials = RED.nodes.getCredentials(req.params.id) || {};
77-
78-
if (newCreds.user == null || newCreds.user == "") {
79-
delete credentials.user;
80-
} else {
81-
credentials.user = newCreds.user;
82-
}
71+
if (newCreds.user == null || newCreds.user == "") {
72+
delete credentials.user;
73+
} else {
74+
credentials.user = newCreds.user;
75+
}
8376

84-
if (newCreds.password == "") {
85-
delete credentials.password;
86-
} else {
87-
credentials.password = newCreds.password || credentials.password;
88-
}
77+
if (newCreds.password == "") {
78+
delete credentials.password;
79+
} else {
80+
credentials.password = newCreds.password || credentials.password;
81+
}
8982

90-
RED.nodes.addCredentials(req.params.id, credentials);
91-
res.send(200);
92-
});
83+
RED.nodes.addCredentials(req.params.id, credentials);
84+
res.send(200);
9385
});
9486

9587
//

0 commit comments

Comments
 (0)