@@ -96,13 +96,9 @@ export async function inviteMembers({
9696 /**
9797 * Optional RBAC role to attach to the invite. When set, accepted
9898 * invites trigger `rbac.setUserRole(rbacRoleId)` after the OrgMember
99- * is created. Caller is responsible for verifying this role is
100- * assignable by the inviter (level + plan tier) — the action layer
101- * does that check before reaching here.
99+ * is created.
102100 *
103- * Legacy `OrgMemberInvite.role` is still set for OSS compatibility.
104- * Owner/Admin RBAC ids map to the legacy `ADMIN`; anything else maps
105- * to legacy `MEMBER`.
101+ * `OrgMemberInvite.role` is still set if the plugin isn't installed.
106102 */
107103 rbacRoleId ?: string | null ;
108104} ) {
@@ -114,12 +110,9 @@ export async function inviteMembers({
114110 throw new Error ( "User does not have access to this organization" ) ;
115111 }
116112
117- // The legacy enum is the source of truth for OSS auth — keep it in
118- // sync with the chosen RBAC role so self-hosters who never install
119- // the plugin still get sensible permissions.
113+ // The legacy enum is the source of truth without the plugin installed.
120114 const legacyRole : "ADMIN" | "MEMBER" =
121- rbacRoleId === SYSTEM_ROLE_IDS . owner ||
122- rbacRoleId === SYSTEM_ROLE_IDS . admin
115+ rbacRoleId === SYSTEM_ROLE_IDS . owner || rbacRoleId === SYSTEM_ROLE_IDS . admin
123116 ? "ADMIN"
124117 : "MEMBER" ;
125118
@@ -240,22 +233,15 @@ export async function acceptInvite({
240233 } ;
241234 } ) ;
242235
243- // If the invite carried an explicit RBAC role (the inviter picked one
244- // when sending the invite), assign it now. Outside the Prisma
245- // transaction because the RBAC plugin runs against a separate
246- // postgres-js connection. Errors are logged, not fatal: the runtime
247- // fallback derives a role from the legacy OrgMember.role write
248- // above, so the user keeps working.
249- //
250- // No rbacRoleId → legacy behaviour, fallback covers it.
236+ // If the invite carried an explicit RBAC role. Errors are logged, not fatal.
251237 if ( result . rbacRoleId ) {
252238 const roleResult = await rbac . setUserRole ( {
253239 userId : user . id ,
254240 organizationId : result . organization . id ,
255241 roleId : result . rbacRoleId ,
256242 } ) ;
257243 if ( ! roleResult . ok ) {
258- logger . debug ( "acceptInvite: skipped RBAC role assignment" , {
244+ logger . error ( "acceptInvite: skipped RBAC role assignment" , {
259245 organizationId : result . organization . id ,
260246 userId : user . id ,
261247 rbacRoleId : result . rbacRoleId ,
0 commit comments