Skip to content

Commit 524267d

Browse files
committed
bump
1 parent a746b4e commit 524267d

9 files changed

Lines changed: 73 additions & 15 deletions

File tree

OpenFlow/src/Audit.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export class Audit {
1212
log.userid = user._id;
1313
log.name = user.name;
1414
log.username = user.username;
15-
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken());
15+
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
16+
.catch((error) => console.error("failed InsertOne in LoginSuccess: " + error));
1617
}
1718
public static ImpersonateSuccess(user: TokenUser, impostor: TokenUser) {
1819
var log: Singin = new Singin();
@@ -24,7 +25,8 @@ export class Audit {
2425
log.impostoruserid = impostor._id;
2526
log.impostorname = impostor.name;
2627
log.impostorusername = impostor.username;
27-
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken());
28+
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
29+
.catch((error) => console.error("failed InsertOne in ImpersonateSuccess: " + error));
2830
}
2931
public static ImpersonateFailed(user: TokenUser, impostor_id: string) {
3032
var log: Singin = new Singin();
@@ -34,7 +36,8 @@ export class Audit {
3436
log.name = user.name;
3537
log.username = user.username;
3638
log.impostoruserid = impostor_id;
37-
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken());
39+
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
40+
.catch((error) => console.error("failed InsertOne in ImpersonateFailed: " + error));
3841
}
3942
public static LoginFailed(username: string, type: string, provider: string, remoteip: string) {
4043
var log: Singin = new Singin();
@@ -43,7 +46,8 @@ export class Audit {
4346
log.type = type;
4447
log.provider = provider;
4548
log.username = username;
46-
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken());
49+
Config.db.InsertOne(log, "audit", 0, false, TokenUser.rootToken())
50+
.catch((error) => console.error("failed InsertOne in LoginFailed: " + error));
4751
}
4852
}
4953
export class Singin extends Base {

OpenFlow/src/DatabaseConnection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { UpdateOneMessage } from "./Messages/UpdateOneMessage";
1313
import { UpdateManyMessage } from "./Messages/UpdateManyMessage";
1414
import { InsertOrUpdateOneMessage } from "./Messages/InsertOrUpdateOneMessage";
1515
import { User } from "./User";
16+
import { Util } from "./Util";
1617
// tslint:disable-next-line: typedef
1718
const safeObjectID = (s: string | number | ObjectID) => ObjectID.isValid(s) ? new ObjectID(s) : null;
1819
export declare function emit(k, v);
@@ -318,8 +319,8 @@ export class DatabaseConnection {
318319
await this.connect();
319320
item = this.ensureResource(item);
320321
DatabaseConnection.traversejsonencode(item);
321-
if (jwt === null || jwt === undefined && collectionname === "jslog") {
322-
jwt = TokenUser.rootToken();
322+
if (Util.IsNullEmpty(jwt)) {
323+
throw new Error("jwt is null");
323324
}
324325
var user: TokenUser = Crypt.verityToken(jwt);
325326
item._createdby = user.name;

OpenFlow/src/Messages/Message.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,12 @@ export class Message {
363363
if (Util.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
364364
if (Util.IsNullEmpty(msg.w as any)) { msg.w = 0; }
365365
if (Util.IsNullEmpty(msg.j as any)) { msg.j = false; }
366-
366+
if (Util.IsNullEmpty(msg.jwt) && msg.collectionname === "jslog") {
367+
msg.jwt = TokenUser.rootToken();
368+
}
369+
if (Util.IsNullEmpty(msg.jwt)) {
370+
throw new Error("jwt is null and client is not authenticated");
371+
}
367372
msg.result = await Config.db.InsertOne(msg.item, msg.collectionname, msg.w, msg.j, msg.jwt);
368373
} catch (error) {
369374
if (Util.IsNullUndefinded(msg)) { (msg as any) = {}; }
@@ -580,6 +585,7 @@ export class Message {
580585
cli.user = user;
581586
} else {
582587
cli._logger.debug(tuser.username + " was validated in using " + type);
588+
// cli.jwt = Crypt.createToken(cli.user, "5m");
583589
}
584590
user.lastseen = new Date(new Date().toISOString());
585591
await user.Save(TokenUser.rootToken());

OpenFlow/src/public/Controllers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,7 @@ module openflow {
14391439
this.loadData();
14401440
} else {
14411441
this.model = new openflow.Form();
1442+
this.model.fbeditor = false;
14421443
this.renderform();
14431444
}
14441445

@@ -1460,6 +1461,7 @@ module openflow {
14601461
if (!this.$scope.$$phase) { this.$scope.$apply(); }
14611462
}
14621463
async renderform() {
1464+
if (this.model.fbeditor == null || this.model.fbeditor == undefined) this.model.fbeditor = true;
14631465
if (this.model.fbeditor == true) {
14641466
// https://www.npmjs.com/package/angular2-json-schema-form
14651467
// http://www.alpacajs.org/demos/form-builder/form-builder.html
@@ -1478,7 +1480,9 @@ module openflow {
14781480
onSave: this.Save.bind(this),
14791481
};
14801482
ele = $(document.getElementById('fb-editor'));
1481-
this.formBuilder = await ele.formBuilder(fbOptions).promise;
1483+
if (this.formBuilder == null || this.formBuilder == undefined) {
1484+
this.formBuilder = await ele.formBuilder(fbOptions).promise;
1485+
}
14821486
} else {
14831487
if (this.model.formData == null || this.model.formData == undefined) { this.model.formData = {}; }
14841488
// "https://examples.form.io/wizard"
@@ -1626,6 +1630,7 @@ module openflow {
16261630
this.loadData();
16271631
}
16281632
async renderform() {
1633+
if (this.form.fbeditor == null || this.form.fbeditor == undefined) this.form.fbeditor = true;
16291634
if (this.form.fbeditor === true) {
16301635
console.debug("renderform");
16311636
var ele: any;

OpenFlow/src/public/EditForm.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
</div>
2222
</div>
2323
</section>
24-
<div id="fb-editor" ng-show="ctrl.model.fbeditor==true"></div>
24+
<div id="fb-editor" ng-show="ctrl.model.fbeditor==true">
25+
</div>
2526
<div ng-show="ctrl.model.fbeditor!=true">
2627
<div class="form-inline">
2728
<label for="sid" class="col-sm-2 control-label" translate lib="web">Wizard</label>
@@ -31,4 +32,5 @@
3132
</div>
3233
</div>
3334
</div>
34-
<div id="builder" ng-show="ctrl.model.fbeditor!=true"></div>
35+
<div id="builder" ng-show="ctrl.model.fbeditor==false">
36+
</div>

OpenFlow/src/public/Form.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<form id="workflowform" ng-submit="ctrl.Save()">
88
<div class="render-wrap" ng-show="ctrl.model.fbeditor==true">
99
</div>
10-
<div id='formio' ng-show="ctrl.model.fbeditor!=true"></div>
10+
<div id='formio' ng-show="ctrl.model.fbeditor!=true">
11+
</div>
1112
</form>

OpenFlowNodeRED/src/node-red-contrib-openflow-storage.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,20 @@ export class noderedcontribopenflowstorage {
165165
}
166166
}
167167
this._logger.info("Installing " + modules);
168-
child_process.execSync("npm install " + modules, { stdio: [0, 1, 2], cwd: this.settings.userDir });
169-
//this.firstrun = false;
170-
//}
168+
var errorcounter = 0;
169+
while (errorcounter < 5) {
170+
try {
171+
child_process.execSync("npm install " + modules, { stdio: [0, 1, 2], cwd: this.settings.userDir });
172+
errorcounter = 10;
173+
} catch (error) {
174+
errorcounter++;
175+
this._logger.error("npm install error");
176+
if (error.status) this._logger.error("npm install status: " + error.status);
177+
if (error.message) this._logger.error("npm install message: " + error.message);
178+
if (error.stderr) this._logger.error("npm install stderr: " + error.stderr);
179+
if (error.stdout) this._logger.error("npm install stdout: " + error.stdout);
180+
}
181+
}
171182
this._logger.silly("noderedcontribopenflowstorage::_getSettings: return result");
172183
return settings;
173184
} catch (error) {

OpenFlowNodeRED/src/nodered/nodes/api_nodes.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ export class api_get {
128128
if (!NoderedUtil.IsNullUndefinded(msg.orderby)) { this.config.orderby = msg.orderby; }
129129
if (!NoderedUtil.IsNullEmpty(msg.top)) { this.config.top = parseInt(msg.top); }
130130
if (!NoderedUtil.IsNullEmpty(msg.skip)) { this.config.skip = parseInt(msg.skip); }
131+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
132+
msg.jwt = Config.jwt;
133+
}
131134

132135
if (NoderedUtil.IsNullEmpty(this.config.top)) { this.config.top = 500; }
133136
if (NoderedUtil.IsNullEmpty(this.config.skip)) { this.config.skip = 0; }
@@ -210,6 +213,10 @@ export class api_add {
210213
if (!NoderedUtil.IsNullEmpty(msg.resultfield)) { this.config.resultfield = msg.resultfield; }
211214
if (!NoderedUtil.IsNullEmpty(msg.writeconcern)) { this.config.writeconcern = msg.writeconcern; }
212215
if (!NoderedUtil.IsNullEmpty(msg.journal)) { this.config.journal = msg.journal; }
216+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
217+
msg.jwt = Config.jwt;
218+
}
219+
213220

214221
if ((this.config.writeconcern as any) === undefined || (this.config.writeconcern as any) === null) this.config.writeconcern = 0;
215222
if ((this.config.journal as any) === undefined || (this.config.journal as any) === null) this.config.journal = false;
@@ -282,6 +289,9 @@ export class api_update {
282289
if (!NoderedUtil.IsNullEmpty(msg.resultfield)) { this.config.resultfield = msg.resultfield; }
283290
if (!NoderedUtil.IsNullEmpty(msg.writeconcern)) { this.config.writeconcern = msg.writeconcern; }
284291
if (!NoderedUtil.IsNullEmpty(msg.journal)) { this.config.journal = msg.journal; }
292+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
293+
msg.jwt = Config.jwt;
294+
}
285295

286296
if ((this.config.writeconcern as any) === undefined || (this.config.writeconcern as any) === null) this.config.writeconcern = 0;
287297
if ((this.config.journal as any) === undefined || (this.config.journal as any) === null) this.config.journal = false;
@@ -355,6 +365,9 @@ export class api_addorupdate {
355365
if (!NoderedUtil.IsNullEmpty(msg.uniqeness)) { this.config.uniqeness = msg.uniqeness; }
356366
if (!NoderedUtil.IsNullEmpty(msg.writeconcern)) { this.config.writeconcern = msg.writeconcern; }
357367
if (!NoderedUtil.IsNullEmpty(msg.journal)) { this.config.journal = msg.journal; }
368+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
369+
msg.jwt = Config.jwt;
370+
}
358371

359372
if ((this.config.writeconcern as any) === undefined || (this.config.writeconcern as any) === null) this.config.writeconcern = 0;
360373
if ((this.config.journal as any) === undefined || (this.config.journal as any) === null) this.config.journal = false;
@@ -421,6 +434,9 @@ export class api_delete {
421434

422435
if (!NoderedUtil.IsNullEmpty(msg.collection)) { this.config.collection = msg.collection; }
423436
if (!NoderedUtil.IsNullEmpty(msg.inputfield)) { this.config.inputfield = msg.inputfield; }
437+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
438+
msg.jwt = Config.jwt;
439+
}
424440

425441
var data: any[] = [];
426442
var _data = NoderedUtil.FetchFromObject(msg, this.config.inputfield);
@@ -490,6 +506,9 @@ export class api_map_reduce {
490506
if (!NoderedUtil.IsNullUndefinded(msg.finalize)) { this.config.finalize = msg.finalize; }
491507
if (!NoderedUtil.IsNullUndefinded(msg.scope)) { this.config.finalize = msg.scope; }
492508
if (!NoderedUtil.IsNullUndefinded(msg.query)) { this.config.query = msg.query; }
509+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
510+
msg.jwt = Config.jwt;
511+
}
493512

494513
var scope = NoderedUtil.FetchFromObject(msg, this.config.scope);
495514
var _output: any = {};
@@ -560,6 +579,9 @@ export class api_updatedocument {
560579
if (!NoderedUtil.IsNullEmpty(msg.collection)) { this.config.collection = msg.collection; }
561580
if (!NoderedUtil.IsNullEmpty(msg.writeconcern)) { this.config.writeconcern = msg.writeconcern; }
562581
if (!NoderedUtil.IsNullEmpty(msg.journal)) { this.config.journal = msg.journal; }
582+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
583+
msg.jwt = Config.jwt;
584+
}
563585

564586
if ((this.config.writeconcern as any) === undefined || (this.config.writeconcern as any) === null) this.config.writeconcern = 0;
565587
if ((this.config.journal as any) === undefined || (this.config.journal as any) === null) this.config.journal = false;
@@ -743,6 +765,9 @@ export class download_file {
743765
// if (NoderedUtil.IsNullEmpty(msg.jwt)) { return NoderedUtil.HandleError(this, "Missing jwt token"); }
744766
if (!NoderedUtil.IsNullEmpty(msg.fileid)) { this.config.fileid = msg.fileid; }
745767
if (!NoderedUtil.IsNullEmpty(msg.filename)) { this.config.filename = msg.filename; }
768+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
769+
msg.jwt = Config.jwt;
770+
}
746771

747772
this.node.status({ fill: "blue", shape: "dot", text: "Getting file" });
748773
var file = await NoderedUtil.GetFile(this.config.filename, this.config.fileid, msg.jwt);
@@ -784,6 +809,9 @@ export class upload_file {
784809
// if (NoderedUtil.IsNullEmpty(msg.jwt)) { return NoderedUtil.HandleError(this, "Missing jwt token"); }
785810
if (!NoderedUtil.IsNullEmpty(msg.filename)) { this.config.filename = msg.filename; }
786811
if (!NoderedUtil.IsNullEmpty(msg.mimeType)) { this.config.mimeType = msg.mimeType; }
812+
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(Config.jwt)) {
813+
msg.jwt = Config.jwt;
814+
}
787815

788816
this.node.status({ fill: "blue", shape: "dot", text: "Saving file" });
789817
var file = await NoderedUtil.SaveFile(this.config.filename, this.config.mimeType, msg.metadata, msg.payload, msg.jwt);

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.371
1+
0.0.372

0 commit comments

Comments
 (0)