diff --git a/apps/dokploy/components/dashboard/settings/billing/show-welcome-dokploy.tsx b/apps/dokploy/components/dashboard/settings/billing/show-welcome-dokploy.tsx index ca6a4dae..9464a565 100644 --- a/apps/dokploy/components/dashboard/settings/billing/show-welcome-dokploy.tsx +++ b/apps/dokploy/components/dashboard/settings/billing/show-welcome-dokploy.tsx @@ -15,7 +15,7 @@ export const ShowWelcomeDokploy = () => { const { data: isCloud, isLoading } = api.settings.isCloud.useQuery(); - if (!isCloud || data?.rol !== "admin") { + if (!isCloud || data?.role !== "admin") { return null; } @@ -24,14 +24,14 @@ export const ShowWelcomeDokploy = () => { !isLoading && isCloud && !localStorage.getItem("hasSeenCloudWelcomeModal") && - data?.rol === "admin" + data?.role === "owner" ) { setOpen(true); } }, [isCloud, isLoading]); const handleClose = (isOpen: boolean) => { - if (data?.rol === "admin") { + if (data?.role === "owner") { setOpen(isOpen); if (!isOpen) { localStorage.setItem("hasSeenCloudWelcomeModal", "true"); // Establece el flag al cerrar el modal diff --git a/apps/dokploy/components/layouts/side.tsx b/apps/dokploy/components/layouts/side.tsx index 88740054..99938a5d 100644 --- a/apps/dokploy/components/layouts/side.tsx +++ b/apps/dokploy/components/layouts/side.tsx @@ -155,7 +155,7 @@ const MENU: Menu = { // Only enabled for admins and users with access to Traefik files in non-cloud environments isEnabled: ({ auth, user, isCloud }) => !!( - (auth?.role === "admin" || user?.canAccessToTraefikFiles) && + (auth?.role === "owner" || user?.canAccessToTraefikFiles) && !isCloud ), }, @@ -166,7 +166,7 @@ const MENU: Menu = { icon: BlocksIcon, // Only enabled for admins and users with access to Docker in non-cloud environments isEnabled: ({ auth, user, isCloud }) => - !!((auth?.role === "admin" || user?.canAccessToDocker) && !isCloud), + !!((auth?.role === "owner" || user?.canAccessToDocker) && !isCloud), }, { isSingle: true, @@ -175,7 +175,7 @@ const MENU: Menu = { icon: PieChart, // Only enabled for admins and users with access to Docker in non-cloud environments isEnabled: ({ auth, user, isCloud }) => - !!((auth?.role === "admin" || user?.canAccessToDocker) && !isCloud), + !!((auth?.role === "owner" || user?.canAccessToDocker) && !isCloud), }, { isSingle: true, @@ -184,7 +184,7 @@ const MENU: Menu = { icon: Forward, // Only enabled for admins and users with access to Docker in non-cloud environments isEnabled: ({ auth, user, isCloud }) => - !!((auth?.role === "admin" || user?.canAccessToDocker) && !isCloud), + !!((auth?.role === "owner" || user?.canAccessToDocker) && !isCloud), }, // Legacy unused menu, adjusted to the new structure @@ -252,7 +252,7 @@ const MENU: Menu = { icon: Activity, // Only enabled for admins in non-cloud environments isEnabled: ({ auth, user, isCloud }) => - !!(auth?.role === "admin" && !isCloud), + !!(auth?.role === "owner" && !isCloud), }, { isSingle: true, @@ -266,7 +266,7 @@ const MENU: Menu = { url: "/dashboard/settings/servers", icon: Server, // Only enabled for admins - isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "admin"), + isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "owner"), }, { isSingle: true, @@ -274,7 +274,7 @@ const MENU: Menu = { icon: Users, url: "/dashboard/settings/users", // Only enabled for admins - isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "admin"), + isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "owner"), }, { isSingle: true, @@ -283,7 +283,7 @@ const MENU: Menu = { url: "/dashboard/settings/ssh-keys", // Only enabled for admins and users with access to SSH keys isEnabled: ({ auth, user }) => - !!(auth?.role === "admin" || user?.canAccessToSSHKeys), + !!(auth?.role === "owner" || user?.canAccessToSSHKeys), }, { isSingle: true, @@ -292,7 +292,7 @@ const MENU: Menu = { icon: GitBranch, // Only enabled for admins and users with access to Git providers isEnabled: ({ auth, user }) => - !!(auth?.role === "admin" || user?.canAccessToGitProviders), + !!(auth?.role === "owner" || user?.canAccessToGitProviders), }, { isSingle: true, @@ -300,7 +300,7 @@ const MENU: Menu = { url: "/dashboard/settings/registry", icon: Package, // Only enabled for admins - isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "admin"), + isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "owner"), }, { isSingle: true, @@ -308,7 +308,7 @@ const MENU: Menu = { url: "/dashboard/settings/destinations", icon: Database, // Only enabled for admins - isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "admin"), + isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "owner"), }, { @@ -317,7 +317,7 @@ const MENU: Menu = { url: "/dashboard/settings/certificates", icon: ShieldCheck, // Only enabled for admins - isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "admin"), + isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "owner"), }, { isSingle: true, @@ -326,7 +326,7 @@ const MENU: Menu = { icon: Boxes, // Only enabled for admins in non-cloud environments isEnabled: ({ auth, user, isCloud }) => - !!(auth?.role === "admin" && !isCloud), + !!(auth?.role === "owner" && !isCloud), }, { isSingle: true, @@ -334,7 +334,7 @@ const MENU: Menu = { url: "/dashboard/settings/notifications", icon: Bell, // Only enabled for admins - isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "admin"), + isEnabled: ({ auth, user, isCloud }) => !!(auth?.role === "owner"), }, { isSingle: true, @@ -343,7 +343,7 @@ const MENU: Menu = { icon: CreditCard, // Only enabled for admins in cloud environments isEnabled: ({ auth, user, isCloud }) => - !!(auth?.role === "admin" && isCloud), + !!(auth?.role === "owner" && isCloud), }, ], @@ -537,7 +537,7 @@ export default function Page({ children }: Props) { authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); @@ -557,7 +557,7 @@ export default function Page({ children }: Props) { // const showProjectsButton = // currentPath === "/dashboard/projects" && - // (auth?.rol === "admin" || user?.canCreateProjects); + // (auth?.rol === "owner" || user?.canCreateProjects); return ( ))} - {!isCloud && auth?.role === "admin" && ( + {!isCloud && auth?.role === "owner" && ( diff --git a/apps/dokploy/components/layouts/user-nav.tsx b/apps/dokploy/components/layouts/user-nav.tsx index 18d459f0..421ea5f2 100644 --- a/apps/dokploy/components/layouts/user-nav.tsx +++ b/apps/dokploy/components/layouts/user-nav.tsx @@ -37,7 +37,7 @@ export const UserNav = () => { authId: data?.id || "", }, { - enabled: !!data?.id && data?.rol === "user", + enabled: !!data?.id && data?.role === "member", }, ); const { locale, setLocale } = useLocale(); @@ -96,7 +96,7 @@ export const UserNav = () => { > Monitoring - {(data?.rol === "admin" || user?.canAccessToTraefikFiles) && ( + {(data?.role === "owner" || user?.canAccessToTraefikFiles) && ( { @@ -106,7 +106,7 @@ export const UserNav = () => { Traefik )} - {(data?.rol === "admin" || user?.canAccessToDocker) && ( + {(data?.role === "owner" || user?.canAccessToDocker) && ( { @@ -119,7 +119,7 @@ export const UserNav = () => { )} - {data?.rol === "admin" && ( + {data?.role === "owner" && ( { @@ -140,7 +140,7 @@ export const UserNav = () => { > Profile - {data?.rol === "admin" && ( + {data?.role === "owner" && ( { @@ -151,7 +151,7 @@ export const UserNav = () => { )} - {data?.rol === "admin" && ( + {data?.role === "owner" && ( { @@ -164,7 +164,7 @@ export const UserNav = () => { )} - {isCloud && data?.rol === "admin" && ( + {isCloud && data?.role === "owner" && ( { diff --git a/apps/dokploy/pages/api/providers/github/setup.ts b/apps/dokploy/pages/api/providers/github/setup.ts index 38a281b1..bd123c68 100644 --- a/apps/dokploy/pages/api/providers/github/setup.ts +++ b/apps/dokploy/pages/api/providers/github/setup.ts @@ -42,7 +42,7 @@ export default async function handler( const auth = await findAuthById(value as string); let adminId = ""; - if (auth.role === "admin") { + if (auth.role === "owner") { const admin = await findAdminByAuthId(auth.id); adminId = admin.adminId; } else { diff --git a/apps/dokploy/pages/dashboard/docker.tsx b/apps/dokploy/pages/dashboard/docker.tsx index 5449b9bd..051e4f0a 100644 --- a/apps/dokploy/pages/dashboard/docker.tsx +++ b/apps/dokploy/pages/dashboard/docker.tsx @@ -53,7 +53,7 @@ export async function getServerSideProps( await helpers.project.all.prefetch(); const auth = await helpers.auth.get.fetch(); - if (auth.role === "user") { + if (auth.role === "member") { const user = await helpers.user.byAuthId.fetch({ authId: auth.id, }); diff --git a/apps/dokploy/pages/dashboard/project/[projectId].tsx b/apps/dokploy/pages/dashboard/project/[projectId].tsx index f8c39a3a..87fa3df4 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId].tsx @@ -206,7 +206,7 @@ const Project = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); const { data, isLoading, refetch } = api.project.one.useQuery({ projectId }); @@ -335,7 +335,7 @@ const Project = ( {data?.description} - {(auth?.role === "admin" || user?.canCreateServices) && ( + {(auth?.role === "owner" || user?.canCreateServices) && (
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx index e2bf8455..441720b9 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/application/[applicationId].tsx @@ -93,7 +93,7 @@ const Service = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); @@ -186,7 +186,7 @@ const Service = (
- {(auth?.role === "admin" || user?.canDeleteServices) && ( + {(auth?.role === "owner" || user?.canDeleteServices) && ( )}
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx index ddc613e5..41a346b4 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/compose/[composeId].tsx @@ -87,7 +87,7 @@ const Service = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); @@ -181,7 +181,7 @@ const Service = (
- {(auth?.role === "admin" || user?.canDeleteServices) && ( + {(auth?.role === "owner" || user?.canDeleteServices) && ( )}
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx index 813ea729..7138be02 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/mariadb/[mariadbId].tsx @@ -68,7 +68,7 @@ const Mariadb = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); const { data: isCloud } = api.settings.isCloud.useQuery(); @@ -154,7 +154,7 @@ const Mariadb = (
- {(auth?.role === "admin" || user?.canDeleteServices) && ( + {(auth?.role === "owner" || user?.canDeleteServices) && ( )}
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx index 0361b7e2..c0ddd96d 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/mongo/[mongoId].tsx @@ -68,7 +68,7 @@ const Mongo = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); @@ -156,7 +156,7 @@ const Mongo = (
- {(auth?.role === "admin" || user?.canDeleteServices) && ( + {(auth?.role === "owner" || user?.canDeleteServices) && ( )}
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx index eff9cfe7..d170bb76 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/mysql/[mysqlId].tsx @@ -67,7 +67,7 @@ const MySql = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); @@ -156,7 +156,7 @@ const MySql = (
- {(auth?.role === "admin" || user?.canDeleteServices) && ( + {(auth?.role === "owner" || user?.canDeleteServices) && ( )}
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx index 808c7aee..67c6a4a5 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/postgres/[postgresId].tsx @@ -66,7 +66,7 @@ const Postgresql = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); const { data: monitoring } = api.admin.getMetricsToken.useQuery(); @@ -154,7 +154,7 @@ const Postgresql = (
- {(auth?.role === "admin" || user?.canDeleteServices) && ( + {(auth?.role === "owner" || user?.canDeleteServices) && ( )}
diff --git a/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx b/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx index 82180401..bb9ebc4a 100644 --- a/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx +++ b/apps/dokploy/pages/dashboard/project/[projectId]/services/redis/[redisId].tsx @@ -67,7 +67,7 @@ const Redis = ( authId: auth?.id || "", }, { - enabled: !!auth?.id && auth?.role === "user", + enabled: !!auth?.id && auth?.role === "member", }, ); @@ -155,7 +155,7 @@ const Redis = (
- {(auth?.role === "admin" || user?.canDeleteServices) && ( + {(auth?.role === "owner" || user?.canDeleteServices) && ( )}
diff --git a/apps/dokploy/pages/dashboard/settings/billing.tsx b/apps/dokploy/pages/dashboard/settings/billing.tsx index dd70c22a..b1a7cb21 100644 --- a/apps/dokploy/pages/dashboard/settings/billing.tsx +++ b/apps/dokploy/pages/dashboard/settings/billing.tsx @@ -30,7 +30,7 @@ export async function getServerSideProps( } const { req, res } = ctx; const { user, session } = await validateRequest(req, res); - if (!user || user.role === "user") { + if (!user || user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/certificates.tsx b/apps/dokploy/pages/dashboard/settings/certificates.tsx index d5bbf033..14d020c4 100644 --- a/apps/dokploy/pages/dashboard/settings/certificates.tsx +++ b/apps/dokploy/pages/dashboard/settings/certificates.tsx @@ -25,7 +25,7 @@ export async function getServerSideProps( ) { const { req, res } = ctx; const { user, session } = await validateRequest(req, res); - if (!user || user.role === "user") { + if (!user || user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/cluster.tsx b/apps/dokploy/pages/dashboard/settings/cluster.tsx index 9affb9ee..dd12723c 100644 --- a/apps/dokploy/pages/dashboard/settings/cluster.tsx +++ b/apps/dokploy/pages/dashboard/settings/cluster.tsx @@ -34,7 +34,7 @@ export async function getServerSideProps( }; } const { user, session } = await validateRequest(ctx.req, ctx.res); - if (!user || user.role === "user") { + if (!user || user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/destinations.tsx b/apps/dokploy/pages/dashboard/settings/destinations.tsx index 671087fe..5d34ec5f 100644 --- a/apps/dokploy/pages/dashboard/settings/destinations.tsx +++ b/apps/dokploy/pages/dashboard/settings/destinations.tsx @@ -26,7 +26,7 @@ export async function getServerSideProps( ) { const { req, res } = ctx; const { user, session } = await validateRequest(req, res); - if (!user || user.role === "user") { + if (!user || user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/git-providers.tsx b/apps/dokploy/pages/dashboard/settings/git-providers.tsx index 6e8bf587..c9135fee 100644 --- a/apps/dokploy/pages/dashboard/settings/git-providers.tsx +++ b/apps/dokploy/pages/dashboard/settings/git-providers.tsx @@ -51,7 +51,7 @@ export async function getServerSideProps( await helpers.settings.isCloud.prefetch(); const auth = await helpers.auth.get.fetch(); - if (auth.role === "user") { + if (auth.role === "member") { const user = await helpers.user.byAuthId.fetch({ authId: auth.id, }); diff --git a/apps/dokploy/pages/dashboard/settings/index.tsx b/apps/dokploy/pages/dashboard/settings/index.tsx index 9b4c8048..577c2b7c 100644 --- a/apps/dokploy/pages/dashboard/settings/index.tsx +++ b/apps/dokploy/pages/dashboard/settings/index.tsx @@ -190,7 +190,7 @@ export async function getServerSideProps( }, }; } - if (user.role === "user") { + if (user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/notifications.tsx b/apps/dokploy/pages/dashboard/settings/notifications.tsx index 054f92e5..840eb9d4 100644 --- a/apps/dokploy/pages/dashboard/settings/notifications.tsx +++ b/apps/dokploy/pages/dashboard/settings/notifications.tsx @@ -26,7 +26,7 @@ export async function getServerSideProps( ) { const { req, res } = ctx; const { user, session } = await validateRequest(req, res); - if (!user || user.role === "user") { + if (!user || user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/profile.tsx b/apps/dokploy/pages/dashboard/settings/profile.tsx index 00f10ec7..1d6d9896 100644 --- a/apps/dokploy/pages/dashboard/settings/profile.tsx +++ b/apps/dokploy/pages/dashboard/settings/profile.tsx @@ -19,7 +19,7 @@ const Page = () => { authId: data?.id || "", }, { - enabled: !!data?.id && data?.role === "user", + enabled: !!data?.id && data?.role === "member", }, ); @@ -28,7 +28,7 @@ const Page = () => {
- {(user?.canAccessToAPI || data?.role === "admin") && } + {(user?.canAccessToAPI || data?.role === "owner") && } {isCloud && }
@@ -62,7 +62,7 @@ export async function getServerSideProps( await helpers.settings.isCloud.prefetch(); await helpers.auth.get.prefetch(); - if (user?.role === "user") { + if (user?.role === "member") { await helpers.user.byAuthId.prefetch({ authId: user.authId, }); diff --git a/apps/dokploy/pages/dashboard/settings/registry.tsx b/apps/dokploy/pages/dashboard/settings/registry.tsx index 441bee39..61f62614 100644 --- a/apps/dokploy/pages/dashboard/settings/registry.tsx +++ b/apps/dokploy/pages/dashboard/settings/registry.tsx @@ -26,7 +26,7 @@ export async function getServerSideProps( ) { const { req, res } = ctx; const { user, session } = await validateRequest(req, res); - if (!user || user.role === "user") { + if (!user || user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/server.tsx b/apps/dokploy/pages/dashboard/settings/server.tsx index 98710d06..498e97ce 100644 --- a/apps/dokploy/pages/dashboard/settings/server.tsx +++ b/apps/dokploy/pages/dashboard/settings/server.tsx @@ -107,7 +107,7 @@ export async function getServerSideProps( }, }; } - if (user.role === "user") { + if (user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/servers.tsx b/apps/dokploy/pages/dashboard/settings/servers.tsx index 27f88be2..6f83fb66 100644 --- a/apps/dokploy/pages/dashboard/settings/servers.tsx +++ b/apps/dokploy/pages/dashboard/settings/servers.tsx @@ -36,7 +36,7 @@ export async function getServerSideProps( }, }; } - if (user.role === "user") { + if (user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx b/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx index fcb11666..d7876641 100644 --- a/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx +++ b/apps/dokploy/pages/dashboard/settings/ssh-keys.tsx @@ -51,7 +51,7 @@ export async function getServerSideProps( const auth = await helpers.auth.get.fetch(); await helpers.settings.isCloud.prefetch(); - if (auth.role === "user") { + if (auth.role === "member") { const user = await helpers.user.byAuthId.fetch({ authId: auth.id, }); diff --git a/apps/dokploy/pages/dashboard/settings/users.tsx b/apps/dokploy/pages/dashboard/settings/users.tsx index ace43969..8f97e2b6 100644 --- a/apps/dokploy/pages/dashboard/settings/users.tsx +++ b/apps/dokploy/pages/dashboard/settings/users.tsx @@ -26,7 +26,7 @@ export async function getServerSideProps( ) { const { req, res } = ctx; const { user, session } = await validateRequest(req, res); - if (!user || user.role === "user") { + if (!user || user.role === "member") { return { redirect: { permanent: true, diff --git a/apps/dokploy/pages/dashboard/swarm.tsx b/apps/dokploy/pages/dashboard/swarm.tsx index 524b464a..f5772820 100644 --- a/apps/dokploy/pages/dashboard/swarm.tsx +++ b/apps/dokploy/pages/dashboard/swarm.tsx @@ -53,7 +53,7 @@ export async function getServerSideProps( await helpers.project.all.prefetch(); const auth = await helpers.auth.get.fetch(); - if (auth.role === "user") { + if (auth.role === "member") { const user = await helpers.user.byAuthId.fetch({ authId: auth.id, }); diff --git a/apps/dokploy/pages/dashboard/traefik.tsx b/apps/dokploy/pages/dashboard/traefik.tsx index b8ff13f3..1f710c9e 100644 --- a/apps/dokploy/pages/dashboard/traefik.tsx +++ b/apps/dokploy/pages/dashboard/traefik.tsx @@ -53,7 +53,7 @@ export async function getServerSideProps( await helpers.project.all.prefetch(); const auth = await helpers.auth.get.fetch(); - if (auth.role === "user") { + if (auth.role === "member") { const user = await helpers.user.byAuthId.fetch({ authId: auth.id, }); diff --git a/apps/dokploy/pages/swagger.tsx b/apps/dokploy/pages/swagger.tsx index 2113e4c8..765194f1 100644 --- a/apps/dokploy/pages/swagger.tsx +++ b/apps/dokploy/pages/swagger.tsx @@ -58,7 +58,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { }, transformer: superjson, }); - if (user.role === "user") { + if (user.role === "member") { const result = await helpers.user.byAuthId.fetch({ authId: user.id, }); diff --git a/apps/dokploy/server/api/routers/admin.ts b/apps/dokploy/server/api/routers/admin.ts index e8467283..55df35af 100644 --- a/apps/dokploy/server/api/routers/admin.ts +++ b/apps/dokploy/server/api/routers/admin.ts @@ -39,7 +39,7 @@ export const adminRouter = createTRPCRouter({ update: adminProcedure .input(apiUpdateAdmin) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { throw new TRPCError({ code: "UNAUTHORIZED", message: "You are not allowed to update this admin", diff --git a/apps/dokploy/server/api/routers/application.ts b/apps/dokploy/server/api/routers/application.ts index 0f7c1eb6..618fd9ce 100644 --- a/apps/dokploy/server/api/routers/application.ts +++ b/apps/dokploy/server/api/routers/application.ts @@ -60,7 +60,7 @@ export const applicationRouter = createTRPCRouter({ .input(apiCreateApplication) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -80,7 +80,7 @@ export const applicationRouter = createTRPCRouter({ } const newApplication = await createApplication(input); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, newApplication.applicationId); } return newApplication; @@ -98,7 +98,7 @@ export const applicationRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindOneApplication) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.applicationId, "access"); } const application = await findApplicationById(input.applicationId); @@ -140,7 +140,7 @@ export const applicationRouter = createTRPCRouter({ delete: protectedProcedure .input(apiFindOneApplication) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.applicationId, "delete"); } const application = await findApplicationById(input.applicationId); diff --git a/apps/dokploy/server/api/routers/auth.ts b/apps/dokploy/server/api/routers/auth.ts index ccb6b5ad..cc149b3c 100644 --- a/apps/dokploy/server/api/routers/auth.ts +++ b/apps/dokploy/server/api/routers/auth.ts @@ -176,6 +176,9 @@ export const authRouter = createTRPCRouter({ eq(member.userId, ctx.user.id), eq(member.organizationId, ctx.session?.activeOrganizationId || ""), ), + with: { + user: true, + }, }); return memberResult; @@ -251,7 +254,7 @@ export const authRouter = createTRPCRouter({ await lucia.invalidateSession(session.id); res.setHeader("Set-Cookie", lucia.createBlankSessionCookie().serialize()); - if (ctx.user.rol === "admin") { + if (ctx.user.rol === "owner") { await removeAdminByAuthId(ctx.user.authId); } else { await removeUserByAuthId(ctx.user.authId); diff --git a/apps/dokploy/server/api/routers/compose.ts b/apps/dokploy/server/api/routers/compose.ts index b3fbae93..69586eb4 100644 --- a/apps/dokploy/server/api/routers/compose.ts +++ b/apps/dokploy/server/api/routers/compose.ts @@ -61,7 +61,7 @@ export const composeRouter = createTRPCRouter({ .input(apiCreateCompose) .mutation(async ({ ctx, input }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -80,7 +80,7 @@ export const composeRouter = createTRPCRouter({ } const newService = await createCompose(input); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, newService.composeId); } @@ -93,7 +93,7 @@ export const composeRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindCompose) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.composeId, "access"); } @@ -122,7 +122,7 @@ export const composeRouter = createTRPCRouter({ delete: protectedProcedure .input(apiDeleteCompose) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.composeId, "delete"); } const composeResult = await findComposeById(input.composeId); @@ -376,7 +376,7 @@ export const composeRouter = createTRPCRouter({ deployTemplate: protectedProcedure .input(apiCreateComposeByTemplate) .mutation(async ({ ctx, input }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -419,7 +419,7 @@ export const composeRouter = createTRPCRouter({ isolatedDeployment: true, }); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, compose.composeId); } diff --git a/apps/dokploy/server/api/routers/mariadb.ts b/apps/dokploy/server/api/routers/mariadb.ts index 9305395d..e50b9b12 100644 --- a/apps/dokploy/server/api/routers/mariadb.ts +++ b/apps/dokploy/server/api/routers/mariadb.ts @@ -37,7 +37,7 @@ export const mariadbRouter = createTRPCRouter({ .input(apiCreateMariaDB) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -56,7 +56,7 @@ export const mariadbRouter = createTRPCRouter({ }); } const newMariadb = await createMariadb(input); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, newMariadb.mariadbId); } @@ -79,7 +79,7 @@ export const mariadbRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindOneMariaDB) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.mariadbId, "access"); } const mariadb = await findMariadbById(input.mariadbId); @@ -201,7 +201,7 @@ export const mariadbRouter = createTRPCRouter({ remove: protectedProcedure .input(apiFindOneMariaDB) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.mariadbId, "delete"); } diff --git a/apps/dokploy/server/api/routers/mongo.ts b/apps/dokploy/server/api/routers/mongo.ts index aed7b4c5..ddb3d3cc 100644 --- a/apps/dokploy/server/api/routers/mongo.ts +++ b/apps/dokploy/server/api/routers/mongo.ts @@ -36,7 +36,7 @@ export const mongoRouter = createTRPCRouter({ .input(apiCreateMongo) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -55,7 +55,7 @@ export const mongoRouter = createTRPCRouter({ }); } const newMongo = await createMongo(input); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, newMongo.mongoId); } @@ -82,7 +82,7 @@ export const mongoRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindOneMongo) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.mongoId, "access"); } @@ -242,7 +242,7 @@ export const mongoRouter = createTRPCRouter({ remove: protectedProcedure .input(apiFindOneMongo) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.mongoId, "delete"); } diff --git a/apps/dokploy/server/api/routers/mysql.ts b/apps/dokploy/server/api/routers/mysql.ts index e66c3094..c81fc842 100644 --- a/apps/dokploy/server/api/routers/mysql.ts +++ b/apps/dokploy/server/api/routers/mysql.ts @@ -38,7 +38,7 @@ export const mysqlRouter = createTRPCRouter({ .input(apiCreateMySql) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -58,7 +58,7 @@ export const mysqlRouter = createTRPCRouter({ } const newMysql = await createMysql(input); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, newMysql.mysqlId); } @@ -85,7 +85,7 @@ export const mysqlRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindOneMySql) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.mysqlId, "access"); } const mysql = await findMySqlById(input.mysqlId); @@ -240,7 +240,7 @@ export const mysqlRouter = createTRPCRouter({ remove: protectedProcedure .input(apiFindOneMySql) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.mysqlId, "delete"); } const mongo = await findMySqlById(input.mysqlId); diff --git a/apps/dokploy/server/api/routers/postgres.ts b/apps/dokploy/server/api/routers/postgres.ts index 0aab4dc6..8a4e8ba2 100644 --- a/apps/dokploy/server/api/routers/postgres.ts +++ b/apps/dokploy/server/api/routers/postgres.ts @@ -44,7 +44,7 @@ export const postgresRouter = createTRPCRouter({ .input(apiCreatePostgres) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -63,7 +63,7 @@ export const postgresRouter = createTRPCRouter({ }); } const newPostgres = await createPostgres(input); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, newPostgres.postgresId); } @@ -90,7 +90,7 @@ export const postgresRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindOnePostgres) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.postgresId, "access"); } @@ -221,7 +221,7 @@ export const postgresRouter = createTRPCRouter({ remove: protectedProcedure .input(apiFindOnePostgres) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.postgresId, "delete"); } const postgres = await findPostgresById(input.postgresId); diff --git a/apps/dokploy/server/api/routers/project.ts b/apps/dokploy/server/api/routers/project.ts index d4a30580..bce12565 100644 --- a/apps/dokploy/server/api/routers/project.ts +++ b/apps/dokploy/server/api/routers/project.ts @@ -36,7 +36,7 @@ export const projectRouter = createTRPCRouter({ .input(apiCreateProject) .mutation(async ({ ctx, input }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkProjectAccess(ctx.user.id, "create"); } @@ -50,7 +50,7 @@ export const projectRouter = createTRPCRouter({ } const project = await createProject(input, ctx.user.ownerId); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewProject(ctx.user.id, project.projectId); } @@ -67,7 +67,7 @@ export const projectRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindOneProject) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { const { accessedServices } = await findUserByAuthId(ctx.user.id); await checkProjectAccess(ctx.user.id, "access", input.projectId); @@ -125,7 +125,7 @@ export const projectRouter = createTRPCRouter({ }), all: protectedProcedure.query(async ({ ctx }) => { // console.log(ctx.user); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { const { accessedProjects, accessedServices } = await findUserById( ctx.user.id, ); @@ -203,7 +203,7 @@ export const projectRouter = createTRPCRouter({ .input(apiRemoveProject) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkProjectAccess(ctx.user.id, "delete"); } const currentProject = await findProjectById(input.projectId); diff --git a/apps/dokploy/server/api/routers/redis.ts b/apps/dokploy/server/api/routers/redis.ts index 46586e5e..acded372 100644 --- a/apps/dokploy/server/api/routers/redis.ts +++ b/apps/dokploy/server/api/routers/redis.ts @@ -36,7 +36,7 @@ export const redisRouter = createTRPCRouter({ .input(apiCreateRedis) .mutation(async ({ input, ctx }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.projectId, "create"); } @@ -55,7 +55,7 @@ export const redisRouter = createTRPCRouter({ }); } const newRedis = await createRedis(input); - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await addNewService(ctx.user.id, newRedis.redisId); } @@ -75,7 +75,7 @@ export const redisRouter = createTRPCRouter({ one: protectedProcedure .input(apiFindOneRedis) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.redisId, "access"); } @@ -232,7 +232,7 @@ export const redisRouter = createTRPCRouter({ remove: protectedProcedure .input(apiFindOneRedis) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { await checkServiceAccess(ctx.user.id, input.redisId, "delete"); } diff --git a/apps/dokploy/server/api/routers/settings.ts b/apps/dokploy/server/api/routers/settings.ts index 6dda9383..cd1f8bd3 100644 --- a/apps/dokploy/server/api/routers/settings.ts +++ b/apps/dokploy/server/api/routers/settings.ts @@ -382,7 +382,7 @@ export const settingsRouter = createTRPCRouter({ .input(apiServerSchema) .query(async ({ ctx, input }) => { try { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { const canAccess = await canAccessToTraefikFiles(ctx.user.authId); if (!canAccess) { @@ -400,7 +400,7 @@ export const settingsRouter = createTRPCRouter({ updateTraefikFile: protectedProcedure .input(apiModifyTraefikConfig) .mutation(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { const canAccess = await canAccessToTraefikFiles(ctx.user.authId); if (!canAccess) { @@ -418,7 +418,7 @@ export const settingsRouter = createTRPCRouter({ readTraefikFile: protectedProcedure .input(apiReadTraefikConfig) .query(async ({ input, ctx }) => { - if (ctx.user.rol === "user") { + if (ctx.user.rol === "member") { const canAccess = await canAccessToTraefikFiles(ctx.user.authId); if (!canAccess) { diff --git a/apps/dokploy/server/api/trpc.ts b/apps/dokploy/server/api/trpc.ts index c88158b8..4e777883 100644 --- a/apps/dokploy/server/api/trpc.ts +++ b/apps/dokploy/server/api/trpc.ts @@ -32,7 +32,7 @@ import { ZodError } from "zod"; interface CreateContextOptions { user: (User & { rol: "admin" | "user"; ownerId: string }) | null; - session: (Session & { activeOrganizationId: string }) | null; + session: (Session & { activeOrganizationId?: string }) | null; req: CreateNextContextOptions["req"]; res: CreateNextContextOptions["res"]; } @@ -67,31 +67,35 @@ export const createTRPCContext = async (opts: CreateNextContextOptions) => { const { req, res } = opts; // Get from the request - let { session, user } = await validateRequest(req); + const { session, user } = await validateRequest(req); - if (!session) { - const cookieResult = await validateRequest(req); - session = cookieResult.session; - user = cookieResult.user; - } + // if (!session) { + // const cookieResult = await validateRequest(req); + // session = cookieResult.session; + // user = cookieResult.user; + // } - console.log("session", { session, user }); + console.log("session", session); + console.log("user", user); return createInnerTRPCContext({ req, res, - session: session, - ...((user && { - user: { - ...user, - email: user.email, - rol: user.role, - id: user.id, - ownerId: user.ownerId, - }, - }) || { - user: null, - }), + session: session + ? { + ...session, + activeOrganizationId: session.activeOrganizationId ?? undefined, + } + : null, + user: user + ? { + ...user, + email: user.email, + rol: user.role as "admin" | "user", + id: user.id, + ownerId: user.ownerId, + } + : null, }); }; diff --git a/packages/server/src/auth/auth.ts b/packages/server/src/auth/auth.ts index 09372fa5..ab18955f 100644 --- a/packages/server/src/auth/auth.ts +++ b/packages/server/src/auth/auth.ts @@ -71,10 +71,10 @@ export async function validateRequest( } if (result.user) { try { - if (result.user?.rol === "admin") { + if (result.user?.rol === "owner") { const admin = await findAdminByAuthId(result.user.id); result.user.adminId = admin.adminId; - } else if (result.user?.rol === "user") { + } else if (result.user?.rol === "member") { const userResult = await findUserByAuthId(result.user.id); result.user.adminId = userResult.adminId; } diff --git a/packages/server/src/auth/token.ts b/packages/server/src/auth/token.ts index f29d4dbd..9dcf9973 100644 --- a/packages/server/src/auth/token.ts +++ b/packages/server/src/auth/token.ts @@ -35,10 +35,10 @@ export const validateBearerToken = async ( const result = await luciaToken.validateSession(sessionId); if (result.user) { - if (result.user?.rol === "admin") { + if (result.user?.rol === "owner") { const admin = await findAdminByAuthId(result.user.id); result.user.adminId = admin.adminId; - } else if (result.user?.rol === "user") { + } else if (result.user?.rol === "member") { const userResult = await findUserByAuthId(result.user.id); result.user.adminId = userResult.adminId; } @@ -73,10 +73,10 @@ export const validateBearerTokenAPI = async ( const result = await luciaToken.validateSession(sessionId); if (result.user) { - if (result.user?.rol === "admin") { + if (result.user?.rol === "owner") { const admin = await findAdminByAuthId(result.user.id); result.user.adminId = admin.adminId; - } else if (result.user?.rol === "user") { + } else if (result.user?.rol === "member") { const userResult = await findUserByAuthId(result.user.id); result.user.adminId = userResult.adminId; } diff --git a/packages/server/src/lib/auth.ts b/packages/server/src/lib/auth.ts index ce636c13..522a921e 100644 --- a/packages/server/src/lib/auth.ts +++ b/packages/server/src/lib/auth.ts @@ -75,9 +75,11 @@ export const auth = betterAuth({ additionalFields: { role: { type: "string", + required: true, }, ownerId: { type: "string", + required: true, }, }, }, diff --git a/packages/server/src/utils/providers/gitlab.ts b/packages/server/src/utils/providers/gitlab.ts index 096f9e28..a2c4b8cc 100644 --- a/packages/server/src/utils/providers/gitlab.ts +++ b/packages/server/src/utils/providers/gitlab.ts @@ -268,7 +268,7 @@ export const getGitlabRepositories = async (gitlabId?: string) => { if (groupName) { return full_path.toLowerCase().includes(groupName) && kind === "group"; } - return kind === "user"; + return kind === "member"; }); const mappedRepositories = filteredRepos.map((repo: any) => { return { @@ -442,7 +442,7 @@ export const testGitlabConnection = async ( if (groupName) { return full_path.toLowerCase().includes(groupName) && kind === "group"; } - return kind === "user"; + return kind === "member"; }); return filteredRepos.length;