@openinc/parse-server-opendash 3.20.0 → 3.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/Tenant.js +3 -0
- package/dist/hooks/_Role.js +3 -3
- package/dist/index.js +9 -0
- package/package.json +1 -1
package/dist/hooks/Tenant.js
CHANGED
|
@@ -54,6 +54,7 @@ async function init() {
|
|
|
54
54
|
await (0, __1.ensureRole)(`od-tenant-admin-${object.id}`, {
|
|
55
55
|
label: `${object.get("label")} (Admin)`,
|
|
56
56
|
});
|
|
57
|
+
console.log("--------> Ensured tenant admin role");
|
|
57
58
|
await (0, __1.ensureRole)(`od-tenant-user-${object.id}`, {
|
|
58
59
|
label: object.get("label"),
|
|
59
60
|
acl: new Parse.ACL({
|
|
@@ -62,7 +63,9 @@ async function init() {
|
|
|
62
63
|
},
|
|
63
64
|
}),
|
|
64
65
|
});
|
|
66
|
+
console.log("--------> Ensured tenant user role");
|
|
65
67
|
if (!original) {
|
|
68
|
+
console.log("--------> Trigger beforeSave after creation");
|
|
66
69
|
// trigger beforeSave after creation
|
|
67
70
|
await object.save(null, {
|
|
68
71
|
useMasterKey: true,
|
package/dist/hooks/_Role.js
CHANGED
|
@@ -9,9 +9,9 @@ async function init() {
|
|
|
9
9
|
if (request.user && request.user.get("tenant")) {
|
|
10
10
|
tenantId = request.user.get("tenant").id;
|
|
11
11
|
}
|
|
12
|
-
if (!role.get("name") && role.isNew()) {
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
//if (!role.get("name") && role.isNew()) {
|
|
13
|
+
// role.set("name", crypto.randomUUID());
|
|
14
|
+
//}
|
|
15
15
|
//Set ACL to od-tenant-admin-{id_of_tenant}
|
|
16
16
|
if (role.isNew()) {
|
|
17
17
|
role.setACL(new Parse.ACL({
|
package/dist/index.js
CHANGED
|
@@ -275,6 +275,7 @@ async function getConfigBoolean(key) {
|
|
|
275
275
|
* @returns A Promise that resolves when the role is successfully created or updated.
|
|
276
276
|
*/
|
|
277
277
|
async function ensureRole(name, options) {
|
|
278
|
+
console.log("--------> Inside ensureRole");
|
|
278
279
|
const label = options?.label || undefined;
|
|
279
280
|
const acl = options?.acl || new Parse.ACL();
|
|
280
281
|
const childRoles = options?.childRoles || undefined;
|
|
@@ -285,19 +286,25 @@ async function ensureRole(name, options) {
|
|
|
285
286
|
.equalTo("name", name)
|
|
286
287
|
.first({ useMasterKey: true });
|
|
287
288
|
if (!role) {
|
|
289
|
+
console.log("--------> Creating role");
|
|
288
290
|
role = new Parse.Role(name, acl);
|
|
289
291
|
role.set("label", label);
|
|
290
292
|
await role.save(null, {
|
|
291
293
|
useMasterKey: true,
|
|
292
294
|
});
|
|
293
295
|
}
|
|
296
|
+
else {
|
|
297
|
+
console.log("--------> Role already exists");
|
|
298
|
+
}
|
|
294
299
|
let changed = false;
|
|
295
300
|
if (role.get("label") !== label) {
|
|
296
301
|
role.set("label", label);
|
|
302
|
+
console.log("--------> Updated role label");
|
|
297
303
|
changed = true;
|
|
298
304
|
}
|
|
299
305
|
if (!(0, fast_equals_1.deepEqual)(acl.toJSON(), role.getACL()?.toJSON())) {
|
|
300
306
|
role.setACL(acl);
|
|
307
|
+
console.log("--------> Updated role ACL");
|
|
301
308
|
changed = true;
|
|
302
309
|
}
|
|
303
310
|
if (Array.isArray(childRoles) && childRoles.length > 0) {
|
|
@@ -314,10 +321,12 @@ async function ensureRole(name, options) {
|
|
|
314
321
|
.equalTo("name", childRoleName)
|
|
315
322
|
.find({ useMasterKey: true });
|
|
316
323
|
relation.add(childRole);
|
|
324
|
+
console.log("--------> Added child role", childRoleName);
|
|
317
325
|
changed = true;
|
|
318
326
|
}
|
|
319
327
|
}
|
|
320
328
|
if (changed) {
|
|
329
|
+
console.log("--------> Saving role");
|
|
321
330
|
await role.save(null, { useMasterKey: true });
|
|
322
331
|
}
|
|
323
332
|
}
|