Skip to content

Commit bd3220a

Browse files
committed
Skip forcing customerid on update
1 parent 6852c34 commit bd3220a

1 file changed

Lines changed: 20 additions & 24 deletions

File tree

OpenFlow/src/DatabaseConnection.ts

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ export class DatabaseConnection extends events.EventEmitter {
314314
if (collectionname == "mq") {
315315
// DBHelper.clearCache("watch detected change in " + collectionname + " collection for a " + _type + " " + item.name);
316316
await DBHelper.memoryCache.del("mq" + item._id);
317+
if (_type == "exchange") await DBHelper.memoryCache.del("exchangename_" + item.name);
318+
if (_type == "queue") await DBHelper.memoryCache.del("queuename_" + item.name);
317319
}
318320
if (collectionname == "users" && (_type == "user" || _type == "role" || _type == "customer")) {
319321
// DBHelper.clearCache("watch detected change in " + collectionname + " collection for a " + _type + " " + item.name);
@@ -1774,31 +1776,25 @@ export class DatabaseConnection extends events.EventEmitter {
17741776
if (customer == null) throw new Error("Access denied to customer with id " + user2.customerid + " when updating " + user2._id);
17751777
} else if (user.HasRoleName("customer admins") && !NoderedUtil.IsNullEmpty(user.customerid)) {
17761778
customer = null;
1777-
if (!NoderedUtil.IsNullEmpty(user.selectedcustomerid)) {
1778-
customer = await this.getbyid<Customer>(user.selectedcustomerid, "users", q.jwt, true, span);
1779-
if (customer != null) user2.customerid = user.selectedcustomerid;
1780-
}
1781-
if (customer == null) {
1782-
if (!user.HasRoleName("admins") && !user.HasRoleName("resellers")) {
1783-
user2.customerid = user.customerid;
1784-
customer = await this.getbyid<Customer>(user2.customerid, "users", q.jwt, true, span);
1785-
if (customer != null) user2.customerid = user.customerid;
1786-
if (customer == null) {
1787-
throw new Error("Access denied to customer with id " + user2.customerid + " when updating " + user2._id);
1788-
}
1789-
}
1790-
}
1791-
// user2.customerid = user.customerid;
1792-
// if (!NoderedUtil.IsNullEmpty(user.selectedcustomerid)) user2.customerid = user.selectedcustomerid;
1793-
// customer = await this.getbyid<Customer>(user2.customerid, "users", q.jwt, true, span);
1779+
// if (!NoderedUtil.IsNullEmpty(user.selectedcustomerid)) {
1780+
// customer = await this.getbyid<Customer>(user.selectedcustomerid, "users", q.jwt, true, span);
1781+
// if (customer != null) user2.customerid = user.selectedcustomerid;
1782+
// }
1783+
// if (customer == null) {
1784+
// if (!user.HasRoleName("admins") && !user.HasRoleName("resellers")) {
1785+
// user2.customerid = user.customerid;
1786+
// customer = await this.getbyid<Customer>(user2.customerid, "users", q.jwt, true, span);
1787+
// if (customer != null) user2.customerid = user.customerid;
1788+
// if (customer == null) {
1789+
// throw new Error("Access denied to customer with id " + user2.customerid + " when updating " + user2._id);
1790+
// }
1791+
// }
1792+
// }
17941793
} else if (Config.multi_tenant && !user.HasRoleName("admins")) {
1795-
// We can update, we just don't want to allow inserts ?
1796-
// throw new Error("Access denied (not admin or customer admin)");
1797-
// user2.customerid = user.customerid;
1798-
if (!NoderedUtil.IsNullEmpty(user.selectedcustomerid)) user2.customerid = user.selectedcustomerid;
1799-
if (!NoderedUtil.IsNullEmpty(user2.customerid)) {
1800-
customer = await this.getbyid<Customer>(user2.customerid, "users", q.jwt, true, span);
1801-
}
1794+
// if (!NoderedUtil.IsNullEmpty(user.selectedcustomerid)) user2.customerid = user.selectedcustomerid;
1795+
// if (!NoderedUtil.IsNullEmpty(user2.customerid)) {
1796+
// customer = await this.getbyid<Customer>(user2.customerid, "users", q.jwt, true, span);
1797+
// }
18021798
}
18031799
if (customer != null && !NoderedUtil.IsNullEmpty(customer.admins)) {
18041800
const custadmins = await this.getbyid<Role>(customer.admins, "users", q.jwt, true, span);

0 commit comments

Comments
 (0)