2 Commits
2 changed files with 12 additions and 16 deletions

No files matched your search

+1 -14
View File
@@ -55,20 +55,7 @@ app.use(express.json({ limit: '10mb' }));
app.use(express.urlencoded({ extended: true, limit: '10mb' }));
app.use(cookieParser());
app.use((req, res, next) => {
if (req.originalUrl && req.originalUrl.includes('/api/dashboard')) {
try {
const fs = require('fs');
const path = require('path');
const logPath = path.join(__dirname, '../scratch/http_requests.log');
const logLine = `[${new Date().toISOString()}] ${req.method} ${req.originalUrl} - Query: ${JSON.stringify(req.query)}\n`;
fs.appendFileSync(logPath, logLine);
} catch (e) {
console.error('Logger error:', e.message);
}
}
next();
});
// ─── Public Routes ────────────────────────────────────────────────────────────
+11 -2
View File
@@ -12,8 +12,17 @@ export async function fetchAgentsFromMongo(
const isCompanyRole = companyRoles.includes(user.role);
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) {
filter.uuid = user.agent_uuid;