@@ -64,8 +64,8 @@ export class api_get_jwt {
6464 if ( ! NoderedUtil . IsNullEmpty ( username ) && ! NoderedUtil . IsNullEmpty ( password ) ) {
6565 q . username = username ; q . password = password ;
6666 } else {
67- if ( Config . jwt !== "" ) {
68- q . jwt = Config . jwt ;
67+ if ( ! NoderedUtil . IsNullUndefinded ( WebSocketClient . instance ) && ! NoderedUtil . IsNullEmpty ( WebSocketClient . instance . jwt ) ) {
68+ q . jwt = WebSocketClient . instance . jwt ;
6969 } else if ( Crypt . encryption_key ( ) !== "" ) {
7070 const user = new TokenUser ( ) ;
7171 if ( NoderedUtil . IsNullEmpty ( Config . nodered_sa ) ) {
@@ -133,9 +133,6 @@ export class api_get {
133133 if ( ! NoderedUtil . IsNullUndefinded ( msg . orderby ) ) { this . config . orderby = msg . orderby ; }
134134 if ( ! NoderedUtil . IsNullEmpty ( msg . top ) ) { this . config . top = parseInt ( msg . top ) ; }
135135 if ( ! NoderedUtil . IsNullEmpty ( msg . skip ) ) { this . config . skip = parseInt ( msg . skip ) ; }
136- // if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
137- // msg.jwt = Config.jwt;
138- // }
139136
140137 if ( NoderedUtil . IsNullEmpty ( this . config . top ) ) { this . config . top = 500 ; }
141138 if ( NoderedUtil . IsNullEmpty ( this . config . skip ) ) { this . config . skip = 0 ; }
@@ -376,17 +373,12 @@ export class api_update {
376373 async oninput ( msg : any ) {
377374 try {
378375 this . node . status ( { } ) ;
379- // if (NoderedUtil.IsNullEmpty(msg.jwt)) { return NoderedUtil.HandleError(this, "Missing jwt token"); }
380-
381376 if ( ! NoderedUtil . IsNullEmpty ( msg . entitytype ) ) { this . config . entitytype = msg . entitytype ; }
382377 if ( ! NoderedUtil . IsNullEmpty ( msg . collection ) ) { this . config . collection = msg . collection ; }
383378 if ( ! NoderedUtil . IsNullEmpty ( msg . inputfield ) ) { this . config . inputfield = msg . inputfield ; }
384379 if ( ! NoderedUtil . IsNullEmpty ( msg . resultfield ) ) { this . config . resultfield = msg . resultfield ; }
385380 if ( ! NoderedUtil . IsNullEmpty ( msg . writeconcern ) ) { this . config . writeconcern = msg . writeconcern ; }
386381 if ( ! NoderedUtil . IsNullEmpty ( msg . journal ) ) { this . config . journal = msg . journal ; }
387- // if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
388- // msg.jwt = Config.jwt;
389- // }
390382
391383 if ( ( this . config . writeconcern as any ) === undefined || ( this . config . writeconcern as any ) === null ) this . config . writeconcern = 0 ;
392384 if ( ( this . config . journal as any ) === undefined || ( this . config . journal as any ) === null ) this . config . journal = false ;
@@ -398,16 +390,6 @@ export class api_update {
398390 if ( data . length === 0 ) { this . node . warn ( "input array is empty" ) ; }
399391 } else { this . node . warn ( "Input data is null" ) ; }
400392
401- // this.node.status({ fill: "blue", shape: "dot", text: "Inserting items" });
402- // const Promises: Promise<any>[] = [];
403- // for (let i: number = 0; i < data.length; i++) {
404- // const element: any = data[i];
405- // if (!NoderedUtil.IsNullEmpty(this.config.entitytype)) {
406- // element._type = this.config.entitytype;
407- // }
408- // Promises.push(NoderedUtil.UpdateOne(this.config.collection, null, element, this.config.writeconcern, this.config.journal, msg.jwt));
409- // }
410- // data = await Promise.all(Promises.map(p => p.catch(e => e)));
411393 this . node . status ( { fill : "blue" , shape : "dot" , text : "processing ..." } ) ;
412394 let Promises : Promise < any > [ ] = [ ] ;
413395 let results : any [ ] = [ ] ;
@@ -678,17 +660,12 @@ export class api_map_reduce {
678660 async oninput ( msg : any ) {
679661 try {
680662 this . node . status ( { } ) ;
681- // if (NoderedUtil.IsNullEmpty(msg.jwt)) { return NoderedUtil.HandleError(this, "Missing jwt token"); }
682-
683663 if ( ! NoderedUtil . IsNullEmpty ( msg . collection ) ) { this . config . collection = msg . collection ; }
684664 if ( ! NoderedUtil . IsNullUndefinded ( msg . map ) ) { this . config . map = msg . map ; }
685665 if ( ! NoderedUtil . IsNullUndefinded ( msg . reduce ) ) { this . config . reduce = msg . reduce ; }
686666 if ( ! NoderedUtil . IsNullUndefinded ( msg . finalize ) ) { this . config . finalize = msg . finalize ; }
687667 if ( ! NoderedUtil . IsNullUndefinded ( msg . scope ) ) { this . config . finalize = msg . scope ; }
688668 if ( ! NoderedUtil . IsNullUndefinded ( msg . query ) ) { this . config . query = msg . query ; }
689- // if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
690- // msg.jwt = Config.jwt;
691- // }
692669
693670 const scope = NoderedUtil . FetchFromObject ( msg , this . config . scope ) ;
694671 const _output : any = { } ;
@@ -846,9 +823,6 @@ export class api_updatedocument {
846823 if ( ! NoderedUtil . IsNullEmpty ( msg . collection ) ) { collection = msg . collection ; }
847824 if ( ! NoderedUtil . IsNullEmpty ( msg . writeconcern ) ) { writeconcern = msg . writeconcern ; }
848825 if ( ! NoderedUtil . IsNullEmpty ( msg . journal ) ) { journal = msg . journal ; }
849- // if (NoderedUtil.IsNullEmpty(jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
850- // jwt = Config.jwt;
851- // }
852826
853827 if ( ( writeconcern as any ) === undefined || ( writeconcern as any ) === null ) writeconcern = 0 ;
854828 if ( ( journal as any ) === undefined || ( journal as any ) === null ) journal = false ;
@@ -1061,9 +1035,6 @@ export class download_file {
10611035
10621036 if ( ! NoderedUtil . IsNullEmpty ( msg . fileid ) ) { this . config . fileid = msg . fileid ; }
10631037 if ( ! NoderedUtil . IsNullEmpty ( msg . filename ) ) { this . config . filename = msg . filename ; }
1064- // if (NoderedUtil.IsNullEmpty(jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
1065- // jwt = Config.jwt;
1066- // }
10671038
10681039 this . node . status ( { fill : "blue" , shape : "dot" , text : "Getting file" } ) ;
10691040 const file = await NoderedUtil . GetFile ( filename , fileid , jwt ) ;
@@ -1108,10 +1079,6 @@ export class upload_file {
11081079 let mimeType = this . config . mimeType ;
11091080 if ( ! NoderedUtil . IsNullEmpty ( msg . filename ) ) { filename = msg . filename ; }
11101081 if ( ! NoderedUtil . IsNullEmpty ( msg . mimeType ) ) { mimeType = msg . mimeType ; }
1111- // if (NoderedUtil.IsNullEmpty(jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
1112- // jwt = Config.jwt;
1113- // }
1114-
11151082
11161083 this . node . status ( { fill : "blue" , shape : "dot" , text : "Saving file" } ) ;
11171084 const file = await NoderedUtil . SaveFile ( filename , mimeType , msg . metadata , msg . payload , jwt ) ;
0 commit comments