Skip to content

Commit ded44df

Browse files
committed
check this.jwt before cli.jwt
1 parent 69c0888 commit ded44df

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

OpenFlow/src/Messages/Message.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,8 @@ export class Message {
896896
if (NoderedUtil.IsNullEmpty(msg.jwt) && !NoderedUtil.IsNullEmpty(msg.data.jwt)) {
897897
msg.jwt = msg.data.jwt;
898898
}
899-
if (NoderedUtil.IsNullEmpty(msg.jwt)) {
900-
msg.jwt = cli.jwt;
901-
}
899+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
900+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
902901
if (!NoderedUtil.IsNullEmpty(msg.jwt)) {
903902
const tuser = Crypt.verityToken(msg.jwt);
904903
msg.user = tuser;
@@ -1153,6 +1152,7 @@ export class Message {
11531152
let msg: WatchMessage
11541153
try {
11551154
msg = WatchMessage.assign(this.data);
1155+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
11561156
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
11571157
if (Config.supports_watch) {
11581158
await cli.UnWatch(msg.id, msg.jwt);
@@ -1178,6 +1178,7 @@ export class Message {
11781178
let msg: WatchMessage
11791179
try {
11801180
msg = WatchMessage.assign(this.data);
1181+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
11811182
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
11821183
if (Config.supports_watch) {
11831184
msg.id = await cli.Watch(msg.aggregates, msg.collectionname, msg.jwt);
@@ -1388,6 +1389,7 @@ export class Message {
13881389
let msg: MapReduceMessage
13891390
try {
13901391
msg = MapReduceMessage.assign(this.data);
1392+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
13911393
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
13921394
msg.result = await Config.db.MapReduce(msg.map, msg.reduce, msg.finalize, msg.query, msg.out, msg.collectionname, msg.scope, msg.jwt);
13931395
delete msg.map;
@@ -3057,6 +3059,7 @@ export class Message {
30573059
let msg: SaveFileMessage
30583060
try {
30593061
msg = SaveFileMessage.assign(this.data);
3062+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
30603063
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
30613064
if (NoderedUtil.IsNullEmpty(msg.filename)) throw new Error("Filename is mandatory");
30623065
if (NoderedUtil.IsNullEmpty(msg.file)) throw new Error("file is mandatory");
@@ -3161,6 +3164,7 @@ export class Message {
31613164
let msg: GetFileMessage
31623165
try {
31633166
msg = SaveFileMessage.assign(this.data);
3167+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
31643168
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
31653169
if (!NoderedUtil.IsNullEmpty(msg.id)) {
31663170
const rows = await Config.db.query({ _id: safeObjectID(msg.id) }, null, 1, 0, null, "files", msg.jwt, undefined, undefined, span);
@@ -3215,6 +3219,7 @@ export class Message {
32153219
let msg: UpdateFileMessage
32163220
try {
32173221
msg = UpdateFileMessage.assign(this.data);
3222+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
32183223
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
32193224

32203225
const bucket = new GridFSBucket(Config.db.db);
@@ -3273,6 +3278,7 @@ export class Message {
32733278
if (NoderedUtil.IsNullEmpty(msg.workflowid) && NoderedUtil.IsNullEmpty(msg.queue)) throw new Error("workflowid or queue is mandatory");
32743279
if (NoderedUtil.IsNullEmpty(msg.resultqueue)) throw new Error("replyqueuename is mandatory");
32753280
if (NoderedUtil.IsNullEmpty(msg.targetid)) throw new Error("targetid is mandatory");
3281+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
32763282
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
32773283
const tuser = Crypt.verityToken(msg.jwt);
32783284
msg.jwt = Crypt.createToken(tuser, Config.longtoken_expires_in);
@@ -3455,7 +3461,8 @@ export class Message {
34553461
const rootjwt = Crypt.rootToken();
34563462
try {
34573463
msg = StripeCancelPlanMessage.assign(this.data);
3458-
if (NoderedUtil.IsNullUndefinded(msg.jwt)) msg.jwt = cli.jwt;
3464+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
3465+
if (NoderedUtil.IsNullUndefinded(msg.jwt)) { msg.jwt = cli.jwt; }
34593466
await this._StripeCancelPlan(msg.resourceusageid, msg.quantity, msg.jwt, span);
34603467

34613468
} catch (error) {
@@ -3486,7 +3493,8 @@ export class Message {
34863493
let msg: GetNextInvoiceMessage;
34873494
try {
34883495
msg = GetNextInvoiceMessage.assign(this.data);
3489-
if (NoderedUtil.IsNullUndefinded(msg.jwt)) msg.jwt = cli.jwt;
3496+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
3497+
if (NoderedUtil.IsNullUndefinded(msg.jwt)) { msg.jwt = cli.jwt; }
34903498

34913499
let payload: any = {};
34923500
const customer: Customer = await Config.db.getbyid(msg.customerid, "users", msg.jwt, span);
@@ -3665,7 +3673,8 @@ export class Message {
36653673
let msg: StripeAddPlanMessage;
36663674
try {
36673675
msg = StripeAddPlanMessage.assign(this.data);
3668-
if (NoderedUtil.IsNullUndefinded(msg.jwt)) msg.jwt = cli.jwt;
3676+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
3677+
if (NoderedUtil.IsNullUndefinded(msg.jwt)) { msg.jwt = cli.jwt; }
36693678
if (NoderedUtil.IsNullUndefinded(msg.userid)) msg.userid = cli.user._id;
36703679
const [customer, checkout] = await this._StripeAddPlan(msg.customerid, msg.userid, msg.resourceid, msg.stripeprice,
36713680
msg.quantity, false, msg.jwt, span);
@@ -4077,7 +4086,8 @@ export class Message {
40774086
let msg: StripeMessage;
40784087
try {
40794088
msg = StripeMessage.assign(this.data);
4080-
if (NoderedUtil.IsNullUndefinded(msg.jwt)) msg.jwt = cli.jwt;
4089+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
4090+
if (NoderedUtil.IsNullUndefinded(msg.jwt)) { msg.jwt = cli.jwt; }
40814091
if (NoderedUtil.IsNullEmpty(msg.object)) throw new Error("object is mandatory");
40824092
if (!cli.user.HasRoleName("admins")) {
40834093
if (!NoderedUtil.IsNullEmpty(msg.url)) throw new Error("Custom url not allowed");
@@ -4125,7 +4135,8 @@ export class Message {
41254135
const rootjwt = Crypt.rootToken();
41264136
try {
41274137
msg = EnsureCustomerMessage.assign(this.data);
4128-
if (NoderedUtil.IsNullUndefinded(msg.jwt)) msg.jwt = cli.jwt;
4138+
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = this.jwt; }
4139+
if (NoderedUtil.IsNullUndefinded(msg.jwt)) { msg.jwt = cli.jwt; }
41294140
let user: User = cli.user;
41304141
let customer: Customer = null;
41314142
if (msg.customer != null && msg.customer._id != null) {

0 commit comments

Comments
 (0)