From 9e781c1f3c18bbc09331a7370b4a6598bfbb04e9 Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 18 Apr 2025 10:19:22 +0200 Subject: [PATCH] clean sidebar 6 --- middleware.ts | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/middleware.ts b/middleware.ts index 2e0032da..cfe4e232 100644 --- a/middleware.ts +++ b/middleware.ts @@ -19,7 +19,7 @@ export default withAuth( return true; } - // For API routes, check if the request is for mail or other protected endpoints + // For API routes, let the route handle its own authentication if (req.nextUrl.pathname.startsWith('/api/')) { // Allow access to public API endpoints if ( @@ -29,29 +29,8 @@ export default withAuth( return true; } - // For protected API endpoints, check if the request has a valid session and token - if (!token || !token.accessToken) { - return false; - } - - // Check if the token has the required roles for the specific service - const path = req.nextUrl.pathname; - const userRoles = token.role || []; - - // Add role checks for specific services - if (path.startsWith('/api/artlab') && !userRoles.includes('Expression')) { - return false; - } - - if (path.startsWith('/api/gite') && !userRoles.includes('DataIntelligence')) { - return false; - } - - if (path.startsWith('/api/calculation') && !userRoles.includes('Calculation')) { - return false; - } - - if (path.startsWith('/api/mediations') && !userRoles.includes('Mediations')) { + // For protected API endpoints, check if the request has a valid session + if (!token) { return false; }