@@ -50,7 +50,7 @@ module.exports = function(RED) {
50
50
if ( credentials ) {
51
51
res . send ( JSON . stringify (
52
52
{
53
- user : credentials . user ,
53
+ username : credentials . username ,
54
54
hasPassword : ( credentials . password && credentials . password !== "" )
55
55
}
56
56
) ) ;
@@ -68,10 +68,10 @@ module.exports = function(RED) {
68
68
var newCreds = req . body ;
69
69
var credentials = RED . nodes . getCredentials ( req . params . id ) || { } ;
70
70
71
- if ( newCreds . user == null || newCreds . user == "" ) {
72
- delete credentials . user ;
71
+ if ( newCreds . username == null || newCreds . username == "" ) {
72
+ delete credentials . username ;
73
73
} else {
74
- credentials . user = newCreds . user ;
74
+ credentials . username = newCreds . username ;
75
75
}
76
76
77
77
if ( newCreds . password == "" ) {
@@ -95,7 +95,7 @@ module.exports = function(RED) {
95
95
96
96
var credentials = RED . nodes . getCredentials ( n . id ) ;
97
97
if ( credentials ) {
98
- this . username = credentials . user ;
98
+ this . username = credentials . username ;
99
99
this . password = credentials . password ;
100
100
}
101
101
@@ -117,11 +117,11 @@ module.exports = function(RED) {
117
117
this . operation = n . operation ;
118
118
this . payonly = n . payonly || false ;
119
119
this . database = n . database ;
120
- this . cloudantConfig = RED . nodes . getNode ( n . cloudant ) ;
120
+ this . cloudantConfig = _getCloudantConfig ( n ) ;
121
121
122
122
var node = this ;
123
123
var credentials = {
124
- account : node . cloudantConfig . credentials . user ,
124
+ account : node . cloudantConfig . credentials . username ,
125
125
password : node . cloudantConfig . credentials . password
126
126
} ;
127
127
@@ -213,7 +213,7 @@ module.exports = function(RED) {
213
213
function CloudantInNode ( n ) {
214
214
RED . nodes . createNode ( this , n ) ;
215
215
216
- this . cloudantConfig = RED . nodes . getNode ( n . cloudant ) ;
216
+ this . cloudantConfig = _getCloudantConfig ( n ) ;
217
217
this . database = n . database ;
218
218
this . search = n . search ;
219
219
this . design = n . design ;
@@ -222,7 +222,7 @@ module.exports = function(RED) {
222
222
223
223
var node = this ;
224
224
var credentials = {
225
- account : node . cloudantConfig . credentials . user ,
225
+ account : node . cloudantConfig . credentials . username ,
226
226
password : node . cloudantConfig . credentials . password
227
227
} ;
228
228
@@ -320,18 +320,11 @@ module.exports = function(RED) {
320
320
}
321
321
RED . nodes . registerType ( "cloudant in" , CloudantInNode ) ;
322
322
323
- function _getUrl ( node , n ) {
324
- if ( n . service == "_ext_" ) {
325
- var cloudantConfig = RED . nodes . getNode ( node . cloudantConfig ) ;
326
- if ( cloudantConfig ) {
327
- return cloudantConfig . url ;
328
- }
329
- }
330
- else if ( n . service != "" ) {
331
- var cloudantConfig = appEnv . getService ( n . service ) ;
332
- if ( cloudantConfig ) {
333
- return cloudantConfig . credentials . url ;
334
- }
323
+ function _getCloudantConfig ( n ) {
324
+ if ( n . service === "_ext_" ) {
325
+ return RED . nodes . getNode ( n . cloudant ) ;
326
+ } else if ( n . service !== "" ) {
327
+ return appEnv . getService ( n . service ) ;
335
328
}
336
329
}
337
330
} ;
0 commit comments