orgAccess(user, null, op) returns vessel access permissions.

If instead of a project ID, orgAccess receives `null`, it will
check permissions against the installation's own vessel rather
than against a specific project.
This commit is contained in:
D. Berge
2025-07-12 16:47:39 +02:00
parent d551e67042
commit 15570e0f3d

View File

@@ -50,11 +50,16 @@ async function vesselOrganisations (vesselID) {
return (await vessel.info(vesselID))?.organisations ?? {};
}
/** Check whether a user has access to the project given by `pid`.
*
* If `pid` is `null`, check against vessel access.
*/
async function orgAccess (userOrgs, pid, operation) {
const projectOrgs = await projectOrganisations(pid);
const itemOrgs = pid === null
? await vesselOrganisations()
: await projectOrganisations(pid);
return access(userOrgs, projectOrgs, operation);
return access(userOrgs, itemOrgs, operation);
}
/*