如何检查AWS Cognito中是否已存在电子邮件? [英] How to check Email Already exists in AWS Cognito?

查看:54
本文介绍了如何检查AWS Cognito中是否已存在电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS Cognito进行登录/注册.离我们只有两个步骤.

I am using AWS Cognito for signin/signup. We have two step from.

1)它会询问您的电子邮件.2)如果电子邮件已经存在,则会询问密码,否则会提示创建密码.根据以上登录或注册条件显示的此步骤上的按钮.

1) It will ask for email. 2) If email already exists then it will ask Password or otherwise it will say create password. Button on this step displayed based on the above condition either Login or Register.

在这里,当用户输入电子邮件后,我需要一种使用AWS javascript SDK登录到cognito的方法,以检查是否已注册电子邮件.

Here after user enters email, I need a way to check in cognito with AWS javascript SDK to check email already registered or not.

谢谢

推荐答案

Amazon Amplify通过Angular/React中aws-amplify的Auth导入,使SignIn和signUp过程非常简单.在我的登录页面上,我要求每个用户注册他们的电子邮件是否确实存储在用户池中.如果用户已注册,则Cognito会引发"UserExistsException"异常,该异常可以捕获在Auth.signUp承诺中,如下所示:

Amazon Amplify makes the signIn and signUp process very straightforward with the Auth importation from aws-amplify in Angular/React. On my login page I ask every user to sign up whether or not their email is alrealdy stored in the user pool. If a user is registered, Cognito raises a "UserExistsException" exception which can be catch in the Auth.signUp promise like so :

公共cognitoSignUp(用户名,密码,电子邮件){Auth.signUp({用户名,密码,属性: {电子邮件,
},validationData:[]}).then(data => {console.log(数据)}).catch(错误=> {//用户已经注册,所以请转到SignIn方法if(error ['code'] ==="UsernameExistsException"){this.cognitoSignIn(用户名,密码);}别的{console.log(错误)}});}

希望我的回答有用.

这篇关于如何检查AWS Cognito中是否已存在电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆