Fix: Server action getAgents now correctly falls back to environment KNOWN_SITES when SITE_UUID is all
This commit is contained in:
1 parent
f61270ddc5
commit
996f685065
1 file changed
+11
-2
@@ -12,8 +12,17 @@ export async function fetchAgentsFromMongo(
|
|||||||
const isCompanyRole = companyRoles.includes(user.role);
|
const isCompanyRole = companyRoles.includes(user.role);
|
||||||
|
|
||||||
const filter: any = {};
|
const filter: any = {};
|
||||||
// Hanya apply site_uuid filter untuk NON-company roles
|
|
||||||
if (SITE_UUID && !isCompanyRole) filter.site_uuid = { $in: [SITE_UUID, 'global'] };
|
if (!isCompanyRole && SITE_UUID) {
|
||||||
|
if (SITE_UUID === 'all') {
|
||||||
|
const envSites = (process.env.BACKONE_SITE_UUIDS || process.env.BACKONE_SITE_UUID || '').split(',').map(s => s.trim()).filter(Boolean);
|
||||||
|
if (envSites.length > 0) {
|
||||||
|
filter.site_uuid = { $in: [...envSites, 'global'] };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
filter.site_uuid = { $in: [SITE_UUID, 'global'] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (user.role === 'AGENT_VIEWER' && user.agent_uuid) {
|
if (user.role === 'AGENT_VIEWER' && user.agent_uuid) {
|
||||||
filter.uuid = user.agent_uuid;
|
filter.uuid = user.agent_uuid;
|
||||||
|
|||||||
Reference in new issue
Block a user