[PR #1693] [CLOSED] fix(types): infer custom Zod roles and support both single & multiple… #3946

Closed
opened 2026-03-13 11:24:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1693
Author: @dionvanhecke
Created: 3/5/2025
Status: Closed

Base: mainHead: patch-1


📝 Commits (1)

  • 5326afa fix(types): infer custom Zod roles and support both single & multiple values

📊 Changes

1 file changed (+13 additions, -11 deletions)

View changed files

📝 packages/better-auth/src/plugins/organization/schema.ts (+13 -11)

📄 Description

This update improves InferZodRolesFromOption to correctly infer custom roles from OrganizationOptions while ensuring support for both single and multiple role values.

why:

Previously, ZodLiteral<> couldn't handle unions or arrays, making it impossible to use both single and multiple role values dynamically. This fix ensures that custom roles are properly inferred, improving flexibility for role-based access control.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/1693 **Author:** [@dionvanhecke](https://github.com/dionvanhecke) **Created:** 3/5/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`5326afa`](https://github.com/better-auth/better-auth/commit/5326afac7b4fcf25968f8b875a31cec0c1eba669) fix(types): infer custom Zod roles and support both single & multiple values ### 📊 Changes **1 file changed** (+13 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/organization/schema.ts` (+13 -11) </details> ### 📄 Description This update improves InferZodRolesFromOption to correctly infer custom roles from OrganizationOptions while ensuring support for both single and multiple role values. why: Previously, ZodLiteral<> couldn't handle unions or arrays, making it impossible to use both single and multiple role values dynamically. This fix ensures that custom roles are properly inferred, improving flexibility for role-based access control. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 11:24:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#3946