UNPKG

@payloadcms/plugin-multi-tenant

Version:
23 lines (22 loc) 832 B
import { getCollectionIDType } from '../utilities/getCollectionIDType.js'; import { getTenantFromCookie } from '../utilities/getTenantFromCookie.js'; /** * Filter the list of users by the selected tenant */ export const filterUsersBySelectedTenant = ({ req, tenantsArrayFieldName, tenantsArrayTenantFieldName, tenantsCollectionSlug })=>{ const idType = getCollectionIDType({ collectionSlug: tenantsCollectionSlug, payload: req.payload }); const selectedTenant = getTenantFromCookie(req.headers, idType); if (selectedTenant) { return { [`${tenantsArrayFieldName}.${tenantsArrayTenantFieldName}`]: { in: [ selectedTenant ] } }; } return {}; }; //# sourceMappingURL=filterUsersBySelectedTenant.js.map