( userId: string, organizationId: string )
| 404 | * @returns Promise<boolean> - True when the user is the organization owner or an admin |
| 405 | */ |
| 406 | export async function isOrganizationAdminOrOwner( |
| 407 | userId: string, |
| 408 | organizationId: string |
| 409 | ): Promise<boolean> { |
| 410 | const [row] = await db |
| 411 | .select({ role: member.role }) |
| 412 | .from(member) |
| 413 | .where(and(eq(member.userId, userId), eq(member.organizationId, organizationId))) |
| 414 | .limit(1) |
| 415 | return isOrgAdminRole(row?.role) |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Check whether a user is a member (any role) of a specific organization. |
no test coverage detected