[BUG] accountLinking options are ignored #1361

Closed
opened 2026-03-13 08:34:55 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @Crea7orX on GitHub (Jun 15, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Set account.accountLinking.enabled: false and attempt to link a Google account.
  2. Set account.accountLinking.allowDifferentEmails: false and attempt to link a Google account with a different email address.

Current vs. Expected behavior

When creating an authentication instance with accountLinking options, these configurations are being ignored, leading to unexpected behavior:

1. Disabling Account Linking:

  • Expected Behavior: When account.accountLinking.enabled is set to false, the user should not be allowed to link their account to external services (e.g., Google).
  • Current Behavior: Despite setting account.accountLinking.enabled = false, the user can still link their Google account by calling await authClient.linkAccount("google"), which is incorrect.

2. Email Mismatch in Account Linking:

  • Expected Behavior: When account.accountLinking.allowDifferentEmails is set to false, users should not be able to link their Google account to a profile with a different email address.
  • Current Behavior: The current implementation allows users to link their Google account to a profile with a different email address, which is incorrect. This flag (allowDifferentEmails) is enforced by the generic-oauth plugin, but should be enforced everywhere.

What version of Better Auth are you using?

1.2.9

Provide environment information

- OS: Windows 11
- Browser: Firefox

Which area(s) are affected? (Select all that apply)

Backend, Documentation

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  socialProviders: {
    google: {
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    },
    github: {
      clientId: env.GITHUB_CLIENT_ID,
      clientSecret: env.GITHUB_CLIENT_SECRET,
    },
  },
  account: {
    accountLinking: {
      enabled: false,
      allowDifferentEmails: false,
    },
  },
});

Additional context

Both issues suggest that the accountLinking options are not being properly respected or enforced in the authentication flow.

Originally created by @Crea7orX on GitHub (Jun 15, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Set `account.accountLinking.enabled: false` and attempt to link a Google account. 2. Set `account.accountLinking.allowDifferentEmails: false` and attempt to link a Google account with a different email address. ### Current vs. Expected behavior When creating an authentication instance with `accountLinking` options, these configurations are being ignored, leading to unexpected behavior: ### 1. Disabling Account Linking: - **Expected Behavior**: When `account.accountLinking.enabled` is set to `false`, the user should not be allowed to link their account to external services (e.g., Google). - **Current Behavior**: Despite setting `account.accountLinking.enabled = false`, the user can still link their Google account by calling `await authClient.linkAccount("google")`, which is incorrect. ### 2. Email Mismatch in Account Linking: - **Expected Behavior**: When `account.accountLinking.allowDifferentEmails` is set to `false`, users should not be able to link their Google account to a profile with a different email address. - **Current Behavior**: The current implementation allows users to link their Google account to a profile with a different email address, which is incorrect. This flag (`allowDifferentEmails`) is enforced by the **generic-oauth** plugin, but should be enforced everywhere. ### What version of Better Auth are you using? 1.2.9 ### Provide environment information ```bash - OS: Windows 11 - Browser: Firefox ``` ### Which area(s) are affected? (Select all that apply) Backend, Documentation ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, socialProviders: { google: { clientId: env.GOOGLE_CLIENT_ID, clientSecret: env.GOOGLE_CLIENT_SECRET, }, github: { clientId: env.GITHUB_CLIENT_ID, clientSecret: env.GITHUB_CLIENT_SECRET, }, }, account: { accountLinking: { enabled: false, allowDifferentEmails: false, }, }, }); ``` ### Additional context Both issues suggest that the `accountLinking` options are not being properly respected or enforced in the authentication flow.
GiteaMirror added the bug label 2026-03-13 08:34:55 -05:00
Author
Owner

@Kinfe123 commented on GitHub (Aug 1, 2025):

from #3739, you can see all test passes and works as intended. closing this issue now. if you think that is not the case , make sure to tag me here.

@Kinfe123 commented on GitHub (Aug 1, 2025): from #3739, you can see all test passes and works as intended. closing this issue now. if you think that is not the case , make sure to tag me here.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1361