Skip to content

Commit 67278d8

Browse files
committed
feat(organization): prevent inviting users with owner role
- Added validation to prevent users from being invited with the owner role in the organization and user routers. - Implemented TRPCError responses to ensure proper error handling when attempting to assign the owner role. This change enhances role management and security within the organization structure. https://github.com/Dokploy/dokploy/security/advisories/GHSA-fm9p-wmpw-gxjh
1 parent aff200f commit 67278d8

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

apps/dokploy/server/api/routers/organization.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ export const organizationRouter = createTRPCRouter({
295295
});
296296
}
297297

298+
// Owner role is non-delegable — no one can invite as owner
299+
if (input.role === "owner") {
300+
throw new TRPCError({
301+
code: "FORBIDDEN",
302+
message: "Cannot invite a user with the owner role",
303+
});
304+
}
305+
298306
// If assigning a custom role, verify it exists
299307
if (!["owner", "admin", "member"].includes(input.role)) {
300308
const customRole = await db.query.organizationRole.findFirst({

apps/dokploy/server/api/routers/user.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,13 @@ export const userRouter = createTRPCRouter({
594594
});
595595
}
596596

597+
if (input.role === "owner") {
598+
throw new TRPCError({
599+
code: "FORBIDDEN",
600+
message: "Cannot create a user with the owner role",
601+
});
602+
}
603+
597604
return await createOrganizationUserWithCredentials({
598605
organizationId: ctx.session.activeOrganizationId,
599606
email: input.email,

0 commit comments

Comments
 (0)