跳至内容

Duplicate User Entries Issue in Amazon Cognito

0

We are using Amazon Cognito as our identity management solution for user registration and authentication. Our requirement is to ensure that each user is uniquely identified by their email address. However, we have noticed that when a user registers using their email, and subsequently registers again using social identity providers such as Google or Facebook, it creates duplicate entries in our user pool, causing data inconsistency.

Issue Description: The problem arises when a user first registers with their email, and later decides to sign in using either Google or Facebook. Instead of updating the existing user entry with the new identity provider, a new user entry is created, leading to multiple accounts for the same email address.

Expected Behavior: We expect Amazon Cognito to identify that the email address is already registered and update the user entry with the additional identity provider data, rather than creating a new entry.

已提问 2 年前1280 查看次数
2 回答
1

Hi, to avoid this, customers usually us the Cognito pre-sign up trigger with a Lambda taking appropriate action based on requirements: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html

There is a good Github repo with sample code: https://github.com/vhalbuquerque/pre-signup-lambda

Best, Didier

专家
已回答 2 年前
专家
已审核 2 年前
0

Thank you for your response. While your solution to preventing duplicate entries in Amazon Cognito is helpful, our specific requirement involves handling social identity provider logins and ensuring a single user entry with multiple linked identities.

We've identified that our issue arises when a user registers with their email and later signs in using social identity providers like Google or Facebook.

So how we can resolve this ?

已回答 2 年前
  • Hi,

    According to the AWS documentation, you can link multiple identity providers (IdPs) to the same user profile in your Cognito directory, usually by automating the AdminLinkProviderForUser action on the pre-signup Lambda trigger, but you will always find both the linked local user and the automatically-created federated user when you search users in your user pool.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。