mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-24 07:28:11 +02:00
Ensure users can only post to pages they have access to
Add access control to the posting route in server/routes.ts to verify user permissions against specified pageIds, preventing unauthorized posts. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/tWDOGLP
This commit is contained in:
1 parent
49871c7b56
commit
82846ab633
1 file changed
+16
@@ -793,6 +793,22 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
return res.status(400).json({ error: "Les stories nécessitent au moins un média (image ou vidéo)" });
|
return res.status(400).json({ error: "Les stories nécessitent au moins un média (image ou vidéo)" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Security: Verify user has access to all specified pages (unless admin)
|
||||||
|
if (user.role !== 'admin' && pageIds && Array.isArray(pageIds) && pageIds.length > 0) {
|
||||||
|
const accessiblePages = await storage.getUserAccessiblePages(userId);
|
||||||
|
const accessiblePageIds = accessiblePages.map(p => p.id);
|
||||||
|
|
||||||
|
const hasAccessToAllPages = pageIds.every(pageId =>
|
||||||
|
accessiblePageIds.includes(pageId)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!hasAccessToAllPages) {
|
||||||
|
return res.status(403).json({
|
||||||
|
error: "Vous n'avez pas accès à certaines pages sélectionnées"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Convert scheduledFor string to Date if provided
|
// Convert scheduledFor string to Date if provided
|
||||||
if (postFields.scheduledFor && typeof postFields.scheduledFor === 'string') {
|
if (postFields.scheduledFor && typeof postFields.scheduledFor === 'string') {
|
||||||
postFields.scheduledFor = new Date(postFields.scheduledFor);
|
postFields.scheduledFor = new Date(postFields.scheduledFor);
|
||||||
|
|||||||
Reference in new issue
Block a user