How to verify if a user with a given email already exists in User Pool?
See original GitHub issueDo you want to request a feature or report a bug?
Question
What is the expected behavior?
Check is user exists
example
Is there such a method?
Auth.verifyIfUserExists({
email: 'foo@bar.com'
})
.then(res => {
// user with this email already exists
})
Because now I can find out if a user exists ONLY during signUp action. But I want to check it before I do signUp. Because if a user doesn’t exist it will be created right off the bat. And it is not what expected
Auth.signUp({
username,
password,
attributes: {
},
})
.then(data => console.log(data))
.catch(err =>{
// User exists !!
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:24
- Comments:39 (2 by maintainers)
Top Results From Across the Web
How to check Email Already exists in AWS Cognito?
1) It will ask for email. 2) If email already exists then it will ask Password or otherwise it will say create password....
Read more >Signing up and confirming user accounts - Amazon Cognito
When you verify your users' email addresses and phone numbers, you ensure that you can contact your users. Complete the following steps in...
Read more >Cognito/Amplify - How to check if user exists? : r/aws - Reddit
User pool app clients have a setting "PreventUserExistenceErrors" that controls whether actions like ForgetPassword throw an error if the ...
Read more >check if user exists in cognito
In order to check if an email already exists in Cognito we have to call .signIn. // Because there is no special method...
Read more >Pre sign-up Lambda trigger - Amazon Cognito
You can set autoVerifyEmail to true to auto-verify the user's email. ... If an alias with that email address already exists, the alias...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
I looked at the amplify source code.
Auth.confirmSignup()callscognitoUser.confirmRegistration(code, forceAliasCreation)which then calls this API: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmSignUp.htmlThe right way to do this (without signIn & signOut) according to the project contributors seems to be this:
@wzup The sign-in workaround might work just because User Pools require passwords that are 6-characters are longer so in practice, there will never be a user account whose password is ‘123’.
@haverchuck However, even if this workaround works, it’s really bad that the API doesn’t support checking the existence of a user name directly. I’ve been working with Cognito for two years and this feature already exists as a request, but hasn’t been implemented yet, along with the ability for an administrator to reset an account’s password. The combination of these two problems makes it quite difficult to build enterprise applications.