Skip to content

External authentication: a customer can get two links of the same provider #900

Open

Description

@KrzysztofPajak

Problem

A customer can end up with two external sign-in links of the same provider (for example two Google accounts attached to one customer).

ExternalAuthenticationService.Authenticate → AuthenticateNewUser → AssociateCustomer(currentLoggedInUser, parameters) (src/Business/Grand.Business.Authentication/Services/ExternalAuthenticationService.cs) runs when a signed-in, registered customer completes Google or Facebook sign-in with an external account that has no link yet. It inserts a new ExternalAuthentication record without checking whether this customer already has a link of that provider.

The account page suggests one link per provider: Views/Account/Info.cshtml offers to add more external records only while the number of active providers is greater than the number of links.

How to reproduce

  1. Enable the Google authentication plugin.
  2. Sign in to the store with a password and connect Google account A (sign in with Google while signed in).
  3. While still signed in, use "Sign in with Google" again and choose Google account B.
  4. My account → external authentication: two Google records for the same customer.

Expected

One link per provider and customer: a second account of the same provider is refused with a clear message (as "Account is already assigned" is today for an external account linked to someone else), or the existing link is replaced after confirmation. A unique index (ProviderSystemName, CustomerId) on ExternalAuthentication would then enforce it for every provider (existing duplicates have to be reported/cleaned up by the migration).

Notes

The OpenID Connect login (stack #892–#897) already enforces one OIDC identity per customer on its own (deterministic link id); this issue is about Google, Facebook and other providers using ExternalAuthenticationService.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions