mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-05 11:42:17 +00:00
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.
This commit is contained in:
@@ -38,21 +38,29 @@ export async function getServerSideProps(
|
|||||||
transformer: superjson,
|
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 {
|
return {
|
||||||
redirect: {
|
props: {
|
||||||
permanent: true,
|
trpcState: helpers.dehydrate(),
|
||||||
destination: "/",
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} catch {
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
trpcState: helpers.dehydrate(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user