[PR #4929] [MERGED] refactor: move parse user input before insert into db #5666

Closed
opened 2026-03-13 12:31:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4929
Author: @himself65
Created: 9/26/2025
Status: Merged
Merged: 9/30/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/09/26/schema


📝 Commits (6)

📊 Changes

6 files changed (+83 additions, -36 deletions)

View changed files

📝 packages/better-auth/src/adapters/adapter-factory/index.ts (+6 -0)
📝 packages/better-auth/src/api/routes/sign-up.test.ts (+27 -8)
📝 packages/better-auth/src/api/routes/sign-up.ts (+25 -14)
📝 packages/better-auth/src/api/routes/update-user.ts (+1 -7)
📝 packages/better-auth/src/db/schema.ts (+23 -6)
📝 packages/better-auth/src/test-utils/test-instance.ts (+1 -1)

📄 Description

I think the timing of checking the schema is weird to me. Trying to move this now to see if it works


Summary by cubic

Move user input parsing into the adapter so all user writes are validated before hitting the DB. This simplifies sign-up and update flows and ensures consistent schema handling.

  • Refactors
    • Parse user input in the adapter for the user model before insert/update.
    • Remove redundant parsing from sign-up and update routes; pass fields through.
    • Make parseOutputData and getAllFields internal.
    • Default parseUserInput to an empty object to avoid undefined cases.

🔄 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/4929 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/26/2025 **Status:** ✅ Merged **Merged:** 9/30/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/26/schema` --- ### 📝 Commits (6) - [`94d9ed7`](https://github.com/better-auth/better-auth/commit/94d9ed7669c360ec3934c4029f9421526a6d0737) refactor: move parse user input before insert into db - [`97bd4aa`](https://github.com/better-auth/better-auth/commit/97bd4aacf249773c6c7e6b922c4c0094108fed08) fix: import - [`cfb8f98`](https://github.com/better-auth/better-auth/commit/cfb8f98cb6ac59ff690a600e2c85976e9776a51e) test: update - [`44363c9`](https://github.com/better-auth/better-auth/commit/44363c92890eb659fe4cb2eac24220064802efc0) fix: code - [`f394389`](https://github.com/better-auth/better-auth/commit/f39438996aeed81f06011c4ea0e47790bda70cc4) Merge branch 'canary' into himself65/2025/09/26/schema - [`fef9220`](https://github.com/better-auth/better-auth/commit/fef9220badb40add6844287b2f04872d907ddc62) chore: lint fix ### 📊 Changes **6 files changed** (+83 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/adapter-factory/index.ts` (+6 -0) 📝 `packages/better-auth/src/api/routes/sign-up.test.ts` (+27 -8) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+25 -14) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+1 -7) 📝 `packages/better-auth/src/db/schema.ts` (+23 -6) 📝 `packages/better-auth/src/test-utils/test-instance.ts` (+1 -1) </details> ### 📄 Description I think the timing of checking the schema is weird to me. Trying to move this now to see if it works <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Move user input parsing into the adapter so all user writes are validated before hitting the DB. This simplifies sign-up and update flows and ensures consistent schema handling. - **Refactors** - Parse user input in the adapter for the user model before insert/update. - Remove redundant parsing from sign-up and update routes; pass fields through. - Make parseOutputData and getAllFields internal. - Default parseUserInput to an empty object to avoid undefined cases. <!-- End of auto-generated description by cubic. --> --- <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 12:31:03 -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#5666