[PR #1265] [CLOSED] feat: Add existing account check for Social Provider sign-up #20625

Closed
opened 2026-04-15 19:49:36 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1265
Author: @arxk
Created: 1/22/2025
Status: Closed

Base: mainHead: feature/add-existing-account-check


📝 Commits (2)

📊 Changes

5 files changed (+79 additions, -11 deletions)

View changed files

📝 docs/content/docs/contribute/testing.mdx (+4 -0)
📝 packages/better-auth/src/api/routes/callback.ts (+10 -0)
📝 packages/better-auth/src/api/routes/sign-up.ts (+1 -1)
📝 packages/better-auth/src/social-providers/social.test.ts (+53 -9)
📝 packages/better-auth/src/test-utils/test-instance.ts (+11 -1)

📄 Description

For anyone who does not have a composite unique constraint on their accountId & providerId fields in their Account model, signing up via any Social Provider will just keep creating accounts with no check for existing ones.

This PR adds a check for an existing account with a lookup of accountId before completing the callback request.

Extra: I also included a Callout in the contributing docs for installing MongoDB, I found out that not having MongoDB installed would just keep giving me "MongoError: connect ECONNREFUSED 127.0.0.1:27017" errors when running test. I also edited the test instance so it attempts an unlink twice & closes the SQLite database before unlinking it as I kept running into errors like "EBUSY: resource busy or locked".


🔄 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/1265 **Author:** [@arxk](https://github.com/arxk) **Created:** 1/22/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/add-existing-account-check` --- ### 📝 Commits (2) - [`a1e9374`](https://github.com/better-auth/better-auth/commit/a1e93747f0233b4fc12211a69043e85ab9eb0f2f) Add existing account check - [`fffdb13`](https://github.com/better-auth/better-auth/commit/fffdb13131dac32c5ed21fd12113b72b978fdf64) Lint fixes ### 📊 Changes **5 files changed** (+79 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/contribute/testing.mdx` (+4 -0) 📝 `packages/better-auth/src/api/routes/callback.ts` (+10 -0) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+1 -1) 📝 `packages/better-auth/src/social-providers/social.test.ts` (+53 -9) 📝 `packages/better-auth/src/test-utils/test-instance.ts` (+11 -1) </details> ### 📄 Description For anyone who does not have a composite unique constraint on their ``accountId`` & ``providerId`` fields in their Account model, signing up via any Social Provider will just keep creating accounts with no check for existing ones. This PR adds a check for an existing account with a lookup of ``accountId`` before completing the callback request. Extra: I also included a Callout in the contributing docs for installing MongoDB, I found out that not having MongoDB installed would just keep giving me "MongoError: connect ECONNREFUSED 127.0.0.1:27017" errors when running ``test``. I also edited the test instance so it attempts an unlink twice & closes the SQLite database before unlinking it as I kept running into errors like "EBUSY: resource busy or locked". --- <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-04-15 19:49:36 -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#20625