* Like `getOrganizationOwnerId` but throws when no owner row exists. * Use when the caller needs a guaranteed billed-account userId — every * Better Auth organization is expected to have exactly one owner, so a * missing owner is a data-integrity issue that should surface loudly.
(organizationId: string)
| 397 | * missing owner is a data-integrity issue that should surface loudly. |
| 398 | */ |
| 399 | async function requireOrganizationOwnerId(organizationId: string): Promise<string> { |
| 400 | const ownerId = await getOrganizationOwnerId(organizationId) |
| 401 | if (!ownerId) { |
| 402 | logger.error('Organization is missing its owner membership row', { organizationId }) |
| 403 | throw new Error(`Organization ${organizationId} has no owner membership`) |
| 404 | } |
| 405 | return ownerId |
| 406 | } |
no test coverage detected