@@ -104,6 +104,29 @@ module.exports = function (RED) {
104104 // have been provided.
105105 this . on ( 'input' , function ( msg ) {
106106
107+ // The dynamic nature of this node has caused problems with the password field. it is
108+ // hidden but not a credential. If it is treated as a credential, it gets lost when there
109+ // is a request to refresh the model list.
110+ //
111+ // Credentials are needed for each of the modes.
112+
113+ username = sUsername || this . credentials . username ;
114+ password = sPassword || this . credentials . password || config . password ;
115+
116+ if ( ! username || ! password ) {
117+ message = 'Missing Language Translation service credentials' ;
118+ node . error ( message , msg ) ;
119+ return ;
120+ }
121+
122+ var action = msg . action || config . action ;
123+
124+ if ( ! action ) {
125+ node . warn ( 'Missing action, please select one' ) ;
126+ node . send ( msg ) ;
127+ return ;
128+ }
129+
107130 // This declaration put here, as codeacy wants it before it is used
108131 // in the do functions below.
109132 var language_translation = watson . language_translation ( {
@@ -278,29 +301,6 @@ module.exports = function (RED) {
278301 return ;
279302 }
280303
281- // The dynamic nature of this node has caused problems with the password field. it is
282- // hidden but not a credential. If it is treated as a credential, it gets lost when there
283- // is a request to refresh the model list.
284- //
285- // Credentials are needed for each of the modes.
286-
287- username = sUsername || this . credentials . username ;
288- password = sPassword || this . credentials . password || config . password ;
289-
290- if ( ! username || ! password ) {
291- message = 'Missing Language Translation service credentials' ;
292- node . error ( message , msg ) ;
293- return ;
294- }
295-
296- var action = msg . action || config . action ;
297-
298- if ( ! action ) {
299- node . warn ( 'Missing action, please select one' ) ;
300- node . send ( msg ) ;
301- return ;
302- }
303-
304304 // We have credentials, and know the mode. Further required fields checks
305305 // are specific to the requested action.
306306 // The required fields are checked, before the relevant function is invoked.
0 commit comments