mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:47:09 +00:00
Add vesselOrganisations() function
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const { setSurvey, pool } = require('../connection');
|
||||
const { ALERT, ERROR, WARNING, NOTICE, INFO, DEBUG } = require('DOUGAL_ROOT/debug')(__filename);
|
||||
const { vessel } = require('../vesel');
|
||||
const { access } = require('../../organisations');
|
||||
const { ALERT, ERROR, WARNING, NOTICE, INFO, DEBUG } = require('DOUGAL_ROOT/debug')(__filename);
|
||||
|
||||
// Cache the per-project organisations access here
|
||||
let projectsCache;
|
||||
@@ -41,7 +42,14 @@ async function projectOrganisations (pid) {
|
||||
return projectsCache[pid] ?? {}; // Every project should have an `organisations` property, but…
|
||||
}
|
||||
|
||||
/** Check whether a user has access to the project given by `pid`
|
||||
/*
|
||||
* Returns organisations associated with a vessel.
|
||||
* If no `vesselID` is provided, returns own vessel.
|
||||
*/
|
||||
async function vesselOrganisations (vesselID) {
|
||||
return (await vessel.info(vesselID))?.organisations ?? {};
|
||||
}
|
||||
|
||||
*/
|
||||
async function orgAccess (userOrgs, pid, operation) {
|
||||
const projectOrgs = await projectOrganisations(pid);
|
||||
@@ -64,6 +72,7 @@ function orgFilter (userOrgs, list, operation, fn = (item) => item.organisations
|
||||
module.exports = {
|
||||
setCache,
|
||||
projectOrganisations,
|
||||
vesselOrganisations,
|
||||
orgAccess,
|
||||
orgFilter
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user