@payloadcms/plugin-multi-tenant
Version:
Multi Tenant plugin for Payload
23 lines (22 loc) • 832 B
JavaScript
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