diff --git a/apps/dokploy/server/api/routers/organization.ts b/apps/dokploy/server/api/routers/organization.ts index 51c1fec5d..6af018ed8 100644 --- a/apps/dokploy/server/api/routers/organization.ts +++ b/apps/dokploy/server/api/routers/organization.ts @@ -295,6 +295,14 @@ export const organizationRouter = createTRPCRouter({ }); } + // Owner role is non-delegable — no one can invite as owner + if (input.role === "owner") { + throw new TRPCError({ + code: "FORBIDDEN", + message: "Cannot invite a user with the owner role", + }); + } + // If assigning a custom role, verify it exists if (!["owner", "admin", "member"].includes(input.role)) { const customRole = await db.query.organizationRole.findFirst({ diff --git a/apps/dokploy/server/api/routers/user.ts b/apps/dokploy/server/api/routers/user.ts index 93b7e6cf6..538cbe7f5 100644 --- a/apps/dokploy/server/api/routers/user.ts +++ b/apps/dokploy/server/api/routers/user.ts @@ -594,6 +594,13 @@ export const userRouter = createTRPCRouter({ }); } + if (input.role === "owner") { + throw new TRPCError({ + code: "FORBIDDEN", + message: "Cannot create a user with the owner role", + }); + } + return await createOrganizationUserWithCredentials({ organizationId: ctx.session.activeOrganizationId, email: input.email,