Skip to content

Commit 0eae538

Browse files
committed
fix
1 parent 9f082fc commit 0eae538

7 files changed

Lines changed: 56 additions & 26 deletions

File tree

OpenFlow/src/DatabaseConnection.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ export class DatabaseConnection {
905905
if (customer != null) {
906906
const custadmins = await this.getbyid<Role>(customer.admins, "users", jwt, span);
907907
Base.addRight(item, custadmins._id, custadmins.name, [Rights.full_control]);
908+
if (item._id == customer.admins || item._id == customer.users) {
909+
Base.removeRight(item, custadmins._id, [Rights.delete]);
910+
}
911+
908912
}
909913
}
910914
j = ((j as any) === 'true' || j === true);
@@ -1314,6 +1318,10 @@ export class DatabaseConnection {
13141318
if (customer != null && !NoderedUtil.IsNullEmpty(customer.admins)) {
13151319
const custadmins = await this.getbyid<Role>(customer.admins, "users", q.jwt, span);
13161320
Base.addRight(q.item, custadmins._id, custadmins.name, [Rights.full_control]);
1321+
if (q.item._id == customer.admins || q.item._id == customer.users) {
1322+
Base.removeRight(q.item, custadmins._id, [Rights.delete]);
1323+
}
1324+
13171325
}
13181326
}
13191327

OpenFlow/src/Messages/Message.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,10 +3714,10 @@ export class Message {
37143714
}
37153715
}
37163716
if (customer == null && cli.user.customerid != null) {
3717-
const customers = await Config.db.query<Customer>({ _type: "customer", "_id": msg.customer._id }, null, 1, 0, null, "users", msg.jwt, undefined, undefined, span);
3718-
if (customers.length > 0) {
3719-
customer = customers[0];
3720-
}
3717+
// const customers = await Config.db.query<Customer>({ _type: "customer", "_id": cli.user.customerid }, null, 1, 0, null, "users", msg.jwt, undefined, undefined, span);
3718+
// if (customers.length > 0) {
3719+
// customer = customers[0];
3720+
// }
37213721
}
37223722

37233723
if (customer == null) {
@@ -3752,6 +3752,7 @@ export class Message {
37523752
customer.vattype = msg.customer.vattype;
37533753
customer.coupon = msg.customer.coupon;
37543754
}
3755+
customer.country = msg.customer.country;
37553756
customer.customattr1 = msg.customer.customattr1;
37563757
customer.customattr2 = msg.customer.customattr2;
37573758
customer.customattr3 = msg.customer.customattr3;
@@ -3805,9 +3806,9 @@ export class Message {
38053806
msg.stripecustomer = await this.Stripe<stripe_customer>("POST", "customers", msg.customer.stripeid, payload2, null);
38063807
}
38073808
if (NoderedUtil.IsNullEmpty(msg.customer._id)) {
3808-
await Config.db.InsertOne(msg.customer, "users", 3, true, rootjwt, span);
3809+
msg.customer = await Config.db.InsertOne(msg.customer, "users", 3, true, rootjwt, span);
38093810
} else {
3810-
await Config.db._UpdateOne(null, msg.customer, "users", 3, true, rootjwt, span);
3811+
msg.customer = await Config.db._UpdateOne(null, msg.customer, "users", 3, true, rootjwt, span);
38113812
}
38123813
if (user.customerid != msg.customer._id) {
38133814
if (NoderedUtil.IsNullEmpty(user.customerid)) user.customerid = msg.customer._id;
@@ -3829,13 +3830,13 @@ export class Message {
38293830
Base.addRight(customeradmins, WellknownIds.admins, "admins", [Rights.full_control]);
38303831
// Base.removeRight(customeradmins, WellknownIds.admins, [Rights.delete]);
38313832
customeradmins.AddMember(user);
3832-
if (!NoderedUtil.IsNullEmpty(user.customerid) && user.customerid != customer._id) {
3833-
const usercustomer = await Config.db.getbyid<Customer>(user.customerid, "users", msg.jwt, span);
3834-
if (usercustomer != null) {
3835-
const usercustomeradmins = await Config.db.getbyid<Role>(usercustomer.admins, "users", msg.jwt, span);
3836-
customeradmins.AddMember(usercustomeradmins);
3837-
}
3838-
}
3833+
// if (!NoderedUtil.IsNullEmpty(user.customerid) && user.customerid != msg.customer._id) {
3834+
// const usercustomer = await Config.db.getbyid<Customer>(user.customerid, "users", msg.jwt, span);
3835+
// if (usercustomer != null) {
3836+
// const usercustomeradmins = await Config.db.getbyid<Role>(usercustomer.admins, "users", msg.jwt, span);
3837+
// if (usercustomeradmins != null) customeradmins.AddMember(usercustomeradmins);
3838+
// }
3839+
// }
38393840
customeradmins.customerid = msg.customer._id;
38403841
await DBHelper.Save(customeradmins, rootjwt, span);
38413842

OpenFlow/src/public/Controllers.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,6 @@ export class UserCtrl extends entityCtrl<TokenUser> {
12891289
// }
12901290
// }
12911291
if (this.removedmembers.length > 0) {
1292-
debugger;
12931292
for (let i = 0; i < this.removedmembers.length; i++) {
12941293
const roles = await NoderedUtil.Query("users", { _type: "role", _id: this.removedmembers[i]._id }, null, { _type: -1, name: 1 }, 5, 0, null, null, null, 2);
12951294
if (roles.length > 0) {
@@ -4951,12 +4950,16 @@ export class CustomerCtrl extends entityCtrl<Customer> {
49514950
if (this.id !== null && this.id !== undefined) {
49524951
this.loadData();
49534952
} else {
4954-
if (!NoderedUtil.IsNullEmpty(user.customerid)) {
4955-
var results = await NoderedUtil.Query(this.collection, { "_type": "customer", "_id": user.customerid }, null, null, 1, 0, null, null, null, 2);
4956-
if (results.length > 0) {
4957-
this.model = results[0];
4958-
console.debug("Loaded customer " + this.model._id);
4953+
user = TokenUser.assign(user);
4954+
if (!user.HasRoleName("resellers")) {
4955+
if (!NoderedUtil.IsNullEmpty(user.customerid)) {
4956+
var results = await NoderedUtil.Query(this.collection, { "_type": "customer", "_id": user.customerid }, null, null, 1, 0, null, null, null, 2);
4957+
if (results.length > 0) {
4958+
this.model = results[0];
4959+
console.debug("Loaded customer " + this.model._id);
4960+
}
49594961
}
4962+
49604963
}
49614964
if (NoderedUtil.IsNullUndefinded(this.model)) {
49624965
this.model = {} as any;
@@ -4972,6 +4975,8 @@ export class CustomerCtrl extends entityCtrl<Customer> {
49724975
this.model.vatnumber = results[0].vatnumber;
49734976
this.model.vattype = results[0].vattype;
49744977
}
4978+
this.model.email = (WebSocketClientService.user as any).username;
4979+
if ((WebSocketClientService.user as any).email) this.model.email = (WebSocketClientService.user as any).email;
49754980
console.debug("Create new customer");
49764981
}
49774982
if (!this.$scope.$$phase) { this.$scope.$apply(); }

OpenFlow/src/public/Customer.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,22 @@ <h1 class="pagetitle" translate lib="web">customer</h1>
298298
</div>
299299
</div>
300300

301+
<div class="form-row row-eq-spacing-sm">
302+
<div class="col-sm">
303+
<label for="email" class="required">billing email</label>
304+
<input type="text" class="form-control" id="email" ng-model="ctrl.model.email" placeholder="Billing email"
305+
required="required">
306+
</div>
307+
<div class="col-sm">
308+
<br> <button type="submit" ng-disabled="ctrl.loading==true" class="btn btn-success" translate lib="web">
309+
Save</button>
310+
</div>
311+
<!-- <div class="col-sm">
312+
<label for="vatnumber" class="required">TAX/VAT ID</label>
313+
<input type="text" class="form-control" id="vatnumber" ng-model="ctrl.model.vatnumber"
314+
placeholder="TAX or VAT number" required="required">
315+
</div> -->
316+
</div>
301317

302318
<div class="form-row row-eq-spacing-sm" ng-show="ctrl.model.stripeid && ctrl.model.stripeid != ''">
303319
<div class="col-sm">
@@ -308,8 +324,8 @@ <h1 class="pagetitle" translate lib="web">customer</h1>
308324

309325
</div>
310326

311-
<div class="text-right">
327+
<!-- <div class="text-right">
312328
<button type="submit" ng-disabled="ctrl.loading==true" class="btn btn-success" translate lib="web">Save</button>
313-
</div>
329+
</div> -->
314330

315331
</form>

OpenFlowNodeRED/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/nodered",
3-
"version": "1.3.23",
3+
"version": "1.3.24",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {
@@ -25,7 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@nodemailer/mailparser2": "^1.0.3",
28-
"@openiap/openflow-api": "^1.0.94",
28+
"@openiap/openflow-api": "^1.0.95",
2929
"@opentelemetry/api": "^0.18.1",
3030
"@opentelemetry/core": "^0.19.0",
3131
"@opentelemetry/exporter-collector-grpc": "^0.19.0",

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.23
1+
1.3.24

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/openflow",
3-
"version": "1.3.23",
3+
"version": "1.3.24",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {
@@ -30,7 +30,7 @@
3030
},
3131
"dependencies": {
3232
"@kubernetes/client-node": "0.14.3",
33-
"@openiap/openflow-api": "^1.0.94",
33+
"@openiap/openflow-api": "^1.0.95",
3434
"@opentelemetry/api": "^0.18.1",
3535
"@opentelemetry/core": "^0.19.0",
3636
"@opentelemetry/exporter-collector-grpc": "^0.19.0",

0 commit comments

Comments
 (0)