clean sidebar 6

This commit is contained in:
alma 2025-04-18 10:19:22 +02:00
parent f692589c6e
commit 9e781c1f3c

View File

@ -19,7 +19,7 @@ export default withAuth(
return true; 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/')) { if (req.nextUrl.pathname.startsWith('/api/')) {
// Allow access to public API endpoints // Allow access to public API endpoints
if ( if (
@ -29,29 +29,8 @@ export default withAuth(
return true; return true;
} }
// For protected API endpoints, check if the request has a valid session and token // For protected API endpoints, check if the request has a valid session
if (!token || !token.accessToken) { if (!token) {
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')) {
return false; return false;
} }