mirror of
https://github.com/dokploy/dokploy.git
synced 2026-06-13 19:09:49 +00:00
a4e9c6e890
- Added new components for displaying and managing audit logs, including a data table and filters for user actions. - Introduced a custom roles management interface, allowing users to create and modify roles with specific permissions. - Updated permission checks to ensure proper access control for audit logs and custom roles. - Refactored existing components to integrate new functionality and improve user experience.
86 lines
2.1 KiB
TypeScript
86 lines
2.1 KiB
TypeScript
import { validateRequest } from "@dokploy/server";
|
|
import { createServerSideHelpers } from "@trpc/react-query/server";
|
|
import type { GetServerSidePropsContext } from "next";
|
|
import type { ReactElement } from "react";
|
|
import superjson from "superjson";
|
|
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
|
|
import { ManageCustomRoles } from "@/components/proprietary/roles/manage-custom-roles";
|
|
import { ShowInvitations } from "@/components/dashboard/settings/users/show-invitations";
|
|
import { ShowUsers } from "@/components/dashboard/settings/users/show-users";
|
|
import { appRouter } from "@/server/api/root";
|
|
import { api } from "@/utils/api";
|
|
|
|
const Page = () => {
|
|
const { data: auth } = api.user.get.useQuery();
|
|
const { data: permissions } = api.user.getPermissions.useQuery();
|
|
const isOwnerOrAdmin = auth?.role === "owner" || auth?.role === "admin";
|
|
const canCreateMembers = permissions?.member.create ?? false;
|
|
|
|
return (
|
|
<div className="flex flex-col gap-4 w-full">
|
|
<ShowUsers />
|
|
{canCreateMembers && <ShowInvitations />}
|
|
{isOwnerOrAdmin && <ManageCustomRoles />}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Page;
|
|
|
|
Page.getLayout = (page: ReactElement) => {
|
|
return <DashboardLayout metaName="Users">{page}</DashboardLayout>;
|
|
};
|
|
export async function getServerSideProps(
|
|
ctx: GetServerSidePropsContext<{ serviceId: string }>,
|
|
) {
|
|
const { req, res } = ctx;
|
|
const { user, session } = await validateRequest(req);
|
|
|
|
if (!user) {
|
|
return {
|
|
redirect: {
|
|
permanent: true,
|
|
destination: "/",
|
|
},
|
|
};
|
|
}
|
|
|
|
const helpers = createServerSideHelpers({
|
|
router: appRouter,
|
|
ctx: {
|
|
req: req as any,
|
|
res: res as any,
|
|
db: null as any,
|
|
session: session as any,
|
|
user: user as any,
|
|
},
|
|
transformer: superjson,
|
|
});
|
|
|
|
try {
|
|
await helpers.user.get.prefetch();
|
|
await helpers.settings.isCloud.prefetch();
|
|
|
|
const userPermissions = await helpers.user.getPermissions.fetch();
|
|
|
|
if (!userPermissions?.member.read) {
|
|
return {
|
|
redirect: {
|
|
permanent: true,
|
|
destination: "/",
|
|
},
|
|
};
|
|
}
|
|
|
|
return {
|
|
props: {
|
|
trpcState: helpers.dehydrate(),
|
|
},
|
|
};
|
|
} catch {
|
|
return {
|
|
props: {},
|
|
};
|
|
}
|
|
}
|