m0dded
m0dded
BABetter Auth
Created by m0dded on 5/14/2025 in #bug-reports
Organization Member Role | Wrong Type
When using Organization Plugin: As per this: https://www.better-auth.com/docs/plugins/organization#update-member-role
await authClient.organization.updateMemberRole({
memberId: "member-id",
role: "admin" // this can also be an array for multiple roles (e.g. ["admin", "sale"])
})
await authClient.organization.updateMemberRole({
memberId: "member-id",
role: "admin" // this can also be an array for multiple roles (e.g. ["admin", "sale"])
})
it says it can support an array for multiple roles however Member Table: https://www.better-auth.com/docs/plugins/organization#member shows role as string - shouldn't this be string[] ? Checking the source code: https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/organization/organization.ts Schema Definition:
member: {
fields: {
role: {
type: "string",
required: true,
...
}
}
}
member: {
fields: {
role: {
type: "string",
required: true,
...
}
}
}
Flattening is happening here:
export function parseRoles(roles: string | string[]): string {
return Array.isArray(roles) ? roles.join(",") : roles;
}
export function parseRoles(roles: string | string[]): string {
return Array.isArray(roles) ? roles.join(",") : roles;
}
this would mean for true support of multiple roles in updateMemberRole we would need to split the string, mutate and join it again and send back? This could lead to serious bug/risk? Hoping you guys can fix this please!
2 replies