From 7f60000641e520dad4e7b14731d00be43aba2d3a Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Thu, 19 Mar 2026 01:35:19 -0600 Subject: [PATCH] refactor(tags): improve server-side permission handling for tag access - Added error handling for user permission fetching in the server-side props. - Implemented a check for tag read permissions, redirecting unauthorized users to the home page. - Enhanced the overall structure of the server-side logic for better clarity and maintainability. --- .../dokploy/pages/dashboard/settings/tags.tsx | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/dokploy/pages/dashboard/settings/tags.tsx b/apps/dokploy/pages/dashboard/settings/tags.tsx index cb5489a30..d22d30c78 100644 --- a/apps/dokploy/pages/dashboard/settings/tags.tsx +++ b/apps/dokploy/pages/dashboard/settings/tags.tsx @@ -38,21 +38,29 @@ export async function getServerSideProps( transformer: superjson, }); - await helpers.settings.isCloud.prefetch(); + try { + await helpers.user.get.prefetch(); + await helpers.settings.isCloud.prefetch(); - await helpers.user.get.prefetch(); + const userPermissions = await helpers.user.getPermissions.fetch(); + + if (!userPermissions?.tag.read) { + return { + redirect: { + permanent: true, + destination: "/", + }, + }; + } - if (!user || user.role === "member") { return { - redirect: { - permanent: true, - destination: "/", + props: { + trpcState: helpers.dehydrate(), }, }; + } catch { + return { + props: {}, + }; } - return { - props: { - trpcState: helpers.dehydrate(), - }, - }; }