[GH-ISSUE #404] Social Link Account Redirect URI Behavior works like sign-in #8254

Closed
opened 2026-04-13 03:20:28 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @geejayjay on GitHub (Nov 3, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/404

Version: v7.0.1

Description:
The social link account redirect URI is the same as social sign-in, resulting in unintended session creation and account log-in and log-out behavior. Specifically, when linking a social account, if the email associated with the social provider does not match the logged-in user's email, the current behavior is to either create a new user account or log in to a different account, rather than linking to the existing logged-in user.

Current Behavior:

  • When the social link redirect URI is invoked, a new session is created, mirroring the social sign-in process.
  • If the email associated with the social provider does not match the logged-in user's email, instead of linking to the existing session, it results in:
    • Logging into an existing account if it finds a match based on the social provider.
    • Creating a new account if no matching user is found.

Expected Behavior:

  1. If linking to a different email is allowed:

    • Create a new entry in the accounts table to track the new email/social account linkage.
  2. If linking to a different email is not allowed:

    • Return a validation error indicating the email mismatch and prevent the linking action.
  3. If the user is linked correctly:

    • Maintain the current session without creating a new one.
Originally created by @geejayjay on GitHub (Nov 3, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/404 **Version:** v7.0.1 **Description:** The social link account redirect URI is the same as social sign-in, resulting in unintended session creation and account log-in and log-out behavior. Specifically, when linking a social account, if the email associated with the social provider does not match the logged-in user's email, the current behavior is to either create a new user account or log in to a different account, rather than linking to the existing logged-in user. **Current Behavior:** - When the social link redirect URI is invoked, a new session is created, mirroring the social sign-in process. - If the email associated with the social provider does not match the logged-in user's email, instead of linking to the existing session, it results in: - Logging into an existing account if it finds a match based on the social provider. - Creating a new account if no matching user is found. **Expected Behavior:** 1. **If linking to a different email is allowed**: - Create a new entry in the accounts table to track the new email/social account linkage. 2. **If linking to a different email is not allowed**: - Return a validation error indicating the email mismatch and prevent the linking action. 3. **If the user is linked correctly**: - Maintain the current session without creating a new one.
GiteaMirror added the locked label 2026-04-13 03:20:28 -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#8254