From f291fc000bcbdac6c2e9c2b830e5d06a7edc2591 Mon Sep 17 00:00:00 2001 From: michaelschal <35957947-michaelschal@users.noreply.replit.com> Date: Fri, 10 Oct 2025 06:11:41 +0000 Subject: [PATCH] Restrict AI features to administrators only for improved control Update routes and sidebar to enforce admin-only access for AI features, including model retrieval, text generation, and history viewing. 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/G1P4XGr --- .replit | 4 ++++ client/src/App.tsx | 2 +- client/src/components/sidebar.tsx | 25 ++++++++++++++++++++++++- server/routes.ts | 6 +++--- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.replit b/.replit index 8bbc693..f9a4cd6 100644 --- a/.replit +++ b/.replit @@ -38,6 +38,10 @@ externalPort = 4200 localPort = 38631 externalPort = 8080 +[[ports]] +localPort = 39065 +externalPort = 8081 + [[ports]] localPort = 40537 externalPort = 3000 diff --git a/client/src/App.tsx b/client/src/App.tsx index 57062bd..7fd12f2 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -69,7 +69,7 @@ function Router() { {() => } {() => } {() => } - {() => } + {() => } {() => } {() => } {() => } diff --git a/client/src/components/sidebar.tsx b/client/src/components/sidebar.tsx index f0154c0..3e6e0a2 100644 --- a/client/src/components/sidebar.tsx +++ b/client/src/components/sidebar.tsx @@ -63,7 +63,6 @@ export default function Sidebar({ onLinkClick }: SidebarProps = {}) { { icon: PlusCircle, label: "Nouvelle publication", href: "/new", badge: null }, { icon: Calendar, label: "Calendrier", href: "/calendar", badge: null }, { icon: Images, label: "Médiathèque", href: "/media", badge: null }, - { icon: Bot, label: "Assistant IA", href: "/ai", badge: null }, ]; const statsItems = [ @@ -212,6 +211,30 @@ export default function Sidebar({ onLinkClick }: SidebarProps = {}) { )} + handleLinkClick("/ai", e)} + className={` + flex items-center gap-3 px-4 py-3 rounded-xl transition-all relative group cursor-pointer + ${location === "/ai" + ? 'bg-gradient-to-r from-primary/10 to-secondary/10 text-primary shadow-sm' + : 'text-muted-foreground hover:bg-sidebar-accent hover:text-foreground' + } + ${isCollapsed ? 'justify-center' : ''} + `} + data-testid="link-assistant-ia" + > + {location === "/ai" && ( +
+ )} + + {!isCollapsed && Assistant IA} + {isCollapsed && ( +
+ Assistant IA +
+ )} +
handleLinkClick("/users", e)} diff --git a/server/routes.ts b/server/routes.ts index 7582533..4b4dcc7 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -424,7 +424,7 @@ export async function registerRoutes(app: Express): Promise { }); // Get available AI models from OpenRouter - app.get("/api/ai/models", requireAuth, async (req, res) => { + app.get("/api/ai/models", requireAdmin, async (req, res) => { try { const models = await openRouterService.getAvailableModels(); res.json({ models }); @@ -435,7 +435,7 @@ export async function registerRoutes(app: Express): Promise { }); // AI text generation - app.post("/api/ai/generate", requireAuth, async (req, res) => { + app.post("/api/ai/generate", requireAdmin, async (req, res) => { try { const user = req.user as User; const userId = user.id; @@ -937,7 +937,7 @@ export async function registerRoutes(app: Express): Promise { }); // AI Generations - app.get("/api/ai/generations", requireAuth, async (req, res) => { + app.get("/api/ai/generations", requireAdmin, async (req, res) => { try { const user = req.user as User; const userId = user.id;