Skip to content

Commit d5a4cea

Browse files
committed
Auto ensure own permissions
1 parent 4375cf3 commit d5a4cea

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

OpenFlow/src/DatabaseConnection.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,13 @@ export class DatabaseConnection {
14121412
else if (exists.length > 1) {
14131413
throw JSON.stringify(query) + " is not uniqe, more than 1 item in collection matches this";
14141414
}
1415-
if (!this.hasAuthorization(user, q.item, Rights.update)) { throw new Error("Access denied, no authorization to InsertOrUpdateOne"); }
1415+
if (!this.hasAuthorization(user, q.item, Rights.update)) {
1416+
Base.addRight(q.item, user._id, user.name, [Rights.full_control], false);
1417+
this.ensureResource(q.item);
1418+
}
1419+
// if (!this.hasAuthorization(user, q.item, Rights.update)) { throw new Error("Access denied, no authorization to InsertOrUpdateOne"); }
1420+
1421+
14161422
if (exists.length == 1) {
14171423
if (Config.log_updates) Logger.instanse.debug("[" + user.username + "][" + q.collectionname + "] InsertOrUpdateOne, Updating found one in database");
14181424
const uq = new UpdateOneMessage();

0 commit comments

Comments
 (0)