[PR #1498] [CLOSED] fix: userId should be unique on 2fa plugin #3831

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1498
Author: @t3duk
Created: 2/19/2025
Status: Closed

Base: mainHead: fix-2fa-backup-codes


📝 Commits (1)

  • 9ca9758 fix: userId should be unique on 2fa

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/plugins/two-factor/schema.ts (+1 -0)

📄 Description

When using the Prisma DB adaptor (haven't tested others) when trying to generate new backup codes (when 2fa is enabled) it fails. This is because when running update (instead of updateMany) a unique field is required in the where.

This works for me, but do let me know if any issues come of this as I would of suspected someone would of already reported this / fixed it before me as it is a pretty core functionality of the 2fa plugin.


🔄 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/1498 **Author:** [@t3duk](https://github.com/t3duk) **Created:** 2/19/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-2fa-backup-codes` --- ### 📝 Commits (1) - [`9ca9758`](https://github.com/better-auth/better-auth/commit/9ca97583f6d4ce77e47f88fddfb7bc8cfca0bab3) fix: userId should be unique on 2fa ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/two-factor/schema.ts` (+1 -0) </details> ### 📄 Description When using the Prisma DB adaptor (haven't tested others) when trying to generate new backup codes (when 2fa is enabled) it fails. This is because when running `update` (instead of `updateMany`) a unique field is required in the `where`. This works for me, but do let me know if any issues come of this as I would of suspected someone would of already reported this / fixed it before me as it is a pretty core functionality of the 2fa plugin. --- <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:16:09 -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#3831