( organization: Organization | null | undefined, userEmail?: string )
| 11 | * Get the role of a user in an organization |
| 12 | */ |
| 13 | export function getUserRole( |
| 14 | organization: Organization | null | undefined, |
| 15 | userEmail?: string |
| 16 | ): string { |
| 17 | if (!userEmail || !organization?.members) { |
| 18 | return 'member' |
| 19 | } |
| 20 | const currentMember = organization.members.find((m) => m.user?.email === userEmail) |
| 21 | return currentMember?.role ?? 'member' |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Check if a user is an admin or owner in an organization |
no outgoing calls
no test coverage detected