Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
996f685065 | ||
|
|
f61270ddc5 |
No files matched your search
+1
-14
@@ -55,20 +55,7 @@ app.use(express.json({ limit: '10mb' }));
|
|||||||
app.use(express.urlencoded({ extended: true, limit: '10mb' }));
|
app.use(express.urlencoded({ extended: true, limit: '10mb' }));
|
||||||
app.use(cookieParser());
|
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 ────────────────────────────────────────────────────────────
|
// ─── Public Routes ────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -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