Cognito allows multiple accounts on same email id

0

Currently, it seems multiple accounts can be created in Cognito using the same email ID. Is there any setting that needs to be changed to avoid this scenario?

1回答
0

you can enforce unique email addresses by using pre-signup Lambda triggers.

Lambda service > Create function" and select "Author from scratch > Choose the "Python 3.x" runtime

example code : please update according to your requirements

import json
import boto3

def lambda_handler(event, context):
    user_pool_id = event['userPoolId']
    email = event['request']['userAttributes']['email']

    cognito = boto3.client('cognito-idp')

    response = cognito.list_users(
        UserPoolId=user_pool_id,
        Filter=f'email = "{email}"'
    )

    if len(response['Users']) > 0:
        raise Exception('An account with this email address already exists.')

    return event

associate the Lambda function with the pre-signup trigger in your user pool

Amazon Cognito service > Manage User Pools > Triggers > Pre sign-up > select created lambda function

profile picture
エキスパート
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ