Additional fields should also be there in response body #1437

Closed
opened 2026-03-13 08:40:04 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @yscoder310 on GitHub (Jun 28, 2025).

Is this suited for github?

  • Yes, this is suited for github

Is your feature request related to a problem? Please describe.

Its really hard and a hassle to get the additional fields if have them in default schemas like for user schema

Describe the solution you'd like

can it be adde

Describe alternatives you've considered

it will help alot in later versions

Additional context

No response

Originally created by @yscoder310 on GitHub (Jun 28, 2025). ### Is this suited for github? - [ ] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Its really hard and a hassle to get the additional fields if have them in default schemas like for user schema ### Describe the solution you'd like can it be adde ### Describe alternatives you've considered it will help alot in later versions ### Additional context _No response_
GiteaMirror added the enhancement label 2026-03-13 08:40:04 -05:00
Author
Owner

@ping-maxwell commented on GitHub (Jul 1, 2025):

Hey what endpoints were you calling?

@ping-maxwell commented on GitHub (Jul 1, 2025): Hey what endpoints were you calling?
Author
Owner

@yscoder310 commented on GitHub (Jul 2, 2025):

I was calling sign-in/email endpoint Actually I wanted additional fields in sign in response body but I get it in only get session api response, for my use case I have to call first sign-in api and then get-session to get the addtional fields but I want it in first call like sign-in

@yscoder310 commented on GitHub (Jul 2, 2025): I was calling sign-in/email endpoint Actually I wanted additional fields in sign in response body but I get it in only get session api response, for my use case I have to call first sign-in api and then get-session to get the addtional fields but I want it in first call like sign-in
Author
Owner

@ping-maxwell commented on GitHub (Jul 4, 2025):

Yeah it's a limitation for now, same with the signUp endpoint.
In the future we hope to make that customizable.

@ping-maxwell commented on GitHub (Jul 4, 2025): Yeah it's a limitation for now, same with the signUp endpoint. In the future we hope to make that customizable.
Author
Owner

@erickweil commented on GitHub (Jul 4, 2025):

The way I see it, when analyzing the source code of signUp, signIn and username plugin to make my own plugin, I found the response is done explicitly choosing which fields to return to prevent "returned false" fields...

But this could be implemented by a helper function, such as getReturnedFields(user), or something similar, that both getSession and all routes who return user data would use.

As a workaround for now, it's possible to use a after hook reading the session to alter the response (using the setCookie response header)

@erickweil commented on GitHub (Jul 4, 2025): The way I see it, when analyzing the source code of signUp, signIn and username plugin to make my own plugin, I found the response is done explicitly choosing which fields to return to prevent "returned false" fields... But this could be implemented by a helper function, such as getReturnedFields(user), or something similar, that both getSession and all routes who return user data would use. As a workaround for now, it's possible to use a after hook reading the session to alter the response (using the setCookie response header)
Author
Owner

@ping-maxwell commented on GitHub (Jul 4, 2025):

Yeah, hooks are the way to go it seems.

@ping-maxwell commented on GitHub (Jul 4, 2025): Yeah, hooks are the way to go it seems.
Author
Owner

@dosubot[bot] commented on GitHub (Oct 3, 2025):

Hi, @yscoder310. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You requested adding more fields to default response schemas (e.g., sign-in response) to reduce the need for multiple API calls.
  • Maintainer ping-maxwell acknowledged this limitation affects sign-in and sign-up endpoints and expressed hope for customizable responses in the future.
  • Contributor erickweil suggested a helper function to unify returned fields and recommended using after hooks as a workaround.
  • The discussion centers on improving usability by including additional user data in initial authentication responses.
  • The issue remains unresolved with no recent updates.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open.
  • Otherwise, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Oct 3, 2025): Hi, @yscoder310. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You requested adding more fields to default response schemas (e.g., sign-in response) to reduce the need for multiple API calls. - Maintainer ping-maxwell acknowledged this limitation affects sign-in and sign-up endpoints and expressed hope for customizable responses in the future. - Contributor erickweil suggested a helper function to unify returned fields and recommended using after hooks as a workaround. - The discussion centers on improving usability by including additional user data in initial authentication responses. - The issue remains unresolved with no recent updates. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open. - Otherwise, this issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1437