@@ -50,7 +50,7 @@ module.exports = function(RED) {
5050 if ( credentials ) {
5151 res . send ( JSON . stringify (
5252 {
53- user : credentials . user ,
53+ username : credentials . username ,
5454 hasPassword : ( credentials . password && credentials . password !== "" )
5555 }
5656 ) ) ;
@@ -68,10 +68,10 @@ module.exports = function(RED) {
6868 var newCreds = req . body ;
6969 var credentials = RED . nodes . getCredentials ( req . params . id ) || { } ;
7070
71- if ( newCreds . user == null || newCreds . user == "" ) {
72- delete credentials . user ;
71+ if ( newCreds . username == null || newCreds . username == "" ) {
72+ delete credentials . username ;
7373 } else {
74- credentials . user = newCreds . user ;
74+ credentials . username = newCreds . username ;
7575 }
7676
7777 if ( newCreds . password == "" ) {
@@ -95,7 +95,7 @@ module.exports = function(RED) {
9595
9696 var credentials = RED . nodes . getCredentials ( n . id ) ;
9797 if ( credentials ) {
98- this . username = credentials . user ;
98+ this . username = credentials . username ;
9999 this . password = credentials . password ;
100100 }
101101
@@ -117,11 +117,11 @@ module.exports = function(RED) {
117117 this . operation = n . operation ;
118118 this . payonly = n . payonly || false ;
119119 this . database = n . database ;
120- this . cloudantConfig = RED . nodes . getNode ( n . cloudant ) ;
120+ this . cloudantConfig = _getCloudantConfig ( n ) ;
121121
122122 var node = this ;
123123 var credentials = {
124- account : node . cloudantConfig . credentials . user ,
124+ account : node . cloudantConfig . credentials . username ,
125125 password : node . cloudantConfig . credentials . password
126126 } ;
127127
@@ -213,7 +213,7 @@ module.exports = function(RED) {
213213 function CloudantInNode ( n ) {
214214 RED . nodes . createNode ( this , n ) ;
215215
216- this . cloudantConfig = RED . nodes . getNode ( n . cloudant ) ;
216+ this . cloudantConfig = _getCloudantConfig ( n ) ;
217217 this . database = n . database ;
218218 this . search = n . search ;
219219 this . design = n . design ;
@@ -222,7 +222,7 @@ module.exports = function(RED) {
222222
223223 var node = this ;
224224 var credentials = {
225- account : node . cloudantConfig . credentials . user ,
225+ account : node . cloudantConfig . credentials . username ,
226226 password : node . cloudantConfig . credentials . password
227227 } ;
228228
@@ -320,18 +320,11 @@ module.exports = function(RED) {
320320 }
321321 RED . nodes . registerType ( "cloudant in" , CloudantInNode ) ;
322322
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 ) ;
335328 }
336329 }
337330} ;
0 commit comments