[GH-ISSUE #3057] One account from one provider #9451

Closed
opened 2026-04-13 04:55:10 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @zispidd on GitHub (Jun 17, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3057

Is it possible to restrict users to linking only one account from a single provider? So that a user cannot link, for example, two Google accounts to one user.

Originally created by @zispidd on GitHub (Jun 17, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3057 Is it possible to restrict users to linking only one account from a single provider? So that a user cannot link, for example, two Google accounts to one user.
GiteaMirror added the locked label 2026-04-13 04:55:10 -05:00
Author
Owner

@tkrebs2 commented on GitHub (Jun 17, 2025):

You could use a hook and check if a provider with that Id already exists in your db and bounce an error message back. I'm assuming you're fetching the account information somehow, just disable the link button on the front end if > 0 providers with "x" id are found. I'm not sure of your use-case but seems there's a few options.

<!-- gh-comment-id:2981634930 --> @tkrebs2 commented on GitHub (Jun 17, 2025): You could use a hook and check if a provider with that Id already exists in your db and bounce an error message back. I'm assuming you're fetching the account information somehow, just disable the link button on the front end if > 0 providers with "x" id are found. I'm not sure of your use-case but seems there's a few options.
Author
Owner

@zispidd commented on GitHub (Jun 18, 2025):

I don't want to trust the user and perform checks only on the front end, but also on the back end, which is why I was wondering if there is a solution available out of the box

<!-- gh-comment-id:2983557113 --> @zispidd commented on GitHub (Jun 18, 2025): I don't want to trust the user and perform checks only on the front end, but also on the back end, which is why I was wondering if there is a solution available out of the box
Author
Owner

@tkrebs2 commented on GitHub (Jun 18, 2025):

No there's nothing out of the box. You would need to use listAccounts() or a db query to check the number of accounts with a certain provider id and disable your user action based on that. You could use a hook to check on the backend as well.

<!-- gh-comment-id:2984787209 --> @tkrebs2 commented on GitHub (Jun 18, 2025): No there's nothing out of the box. You would need to use `listAccounts()` or a db query to check the number of accounts with a certain provider id and disable your user action based on that. You could use a hook to check on the backend as well.
Author
Owner

@dosubot[bot] commented on GitHub (Sep 17, 2025):

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

Issue Summary:

  • You asked about restricting users to linking only one account per provider.
  • The maintainer clarified there is no built-in solution for this.
  • The recommended approach is to implement custom backend logic, such as hooks or database queries.
  • You emphasized the importance of backend validation over frontend checks.
  • The consensus is to handle this restriction via custom backend implementation.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of better-auth by commenting here.
  • If no further activity occurs, I will automatically close this issue in 7 days.

Thanks for your understanding and contribution!

<!-- gh-comment-id:3303664062 --> @dosubot[bot] commented on GitHub (Sep 17, 2025): Hi, @zispidd. 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 asked about restricting users to linking only one account per provider. - The maintainer clarified there is no built-in solution for this. - The recommended approach is to implement custom backend logic, such as hooks or database queries. - You emphasized the importance of backend validation over frontend checks. - The consensus is to handle this restriction via custom backend implementation. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of better-auth by commenting here. - If no further activity occurs, I will automatically close this issue in 7 days. Thanks 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#9451