mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 08:12:40 +10:00
feat: add acl to notifications
not sure if i got all the acls of the different notifications down rn, but it seems to be about right
This commit is contained in:
@ -55,6 +55,7 @@ export default defineClientEventHandler(
|
||||
title: `"${client.name}" can now access ${capability}`,
|
||||
description: `A device called "${client.name}" now has access to your ${capability}.`,
|
||||
actions: ["Review|/account/devices"],
|
||||
requiredPerms: ["clients:read"],
|
||||
});
|
||||
|
||||
return {};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import aclManager, { type SystemACL } from "~/server/internal/acls";
|
||||
import prisma from "~/server/internal/db/database";
|
||||
|
||||
export default defineEventHandler(async (h3) => {
|
||||
@ -22,5 +22,36 @@ export default defineEventHandler(async (h3) => {
|
||||
},
|
||||
});
|
||||
|
||||
let i = notifications.length;
|
||||
while (i--) {
|
||||
const notif = notifications[i];
|
||||
|
||||
const hasPermsForNotif = await aclManager.allowSystemACL(
|
||||
h3,
|
||||
notif.requiredPerms as SystemACL,
|
||||
);
|
||||
|
||||
if (!hasPermsForNotif) {
|
||||
// remove element
|
||||
console.log(
|
||||
userId,
|
||||
"did not have perms to access",
|
||||
notif.id,
|
||||
"based on",
|
||||
notif.requiredPerms,
|
||||
);
|
||||
|
||||
notifications.splice(i, 1);
|
||||
} else {
|
||||
console.log(
|
||||
userId,
|
||||
"had perms to access",
|
||||
notif.id,
|
||||
"based on",
|
||||
notif.requiredPerms,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return notifications;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user