Signup with AWS Cognito


#41

You would need to double check this but e.message === 'User is already confirmed.' is one way to check. I think Amplify will be standardizing these errors at some point but you can use this for now.


#42

Hmm, that won’t work since the initial e.name is already “UsernameExistsException”. Isn’t there a way to check the status of UNCONFIRMED by using this.state.email ?


#43

Yeah I’ve used something like this in the past.

When calling Auth.resendSignUp check for the error to match this condition (e.name === 'InvalidParameterException' && e.message === 'User is already confirmed.'). This will tell you that the user with that email is already confirmed.

Is that what you are looking for?


#44

Is there something I can use in the API that doesn’t involve e? Like a method of some sort?


#45

I’m actually not sure. A good place to ask is the AWS Amplify Gitter. If you do find out, please report back!


#46

Why does e in catch block have an inconsistent type?

Its type is string if we catch it from await Auth.signIn().
However, it is object type containing a message property when we catch it from await Auth.signUp() and await Auth.confirmSignUp().


#47

The errors that Amplify throws aren’t great. But for Auth.signIn, we are doing e.message as well right?

Do we have a typo in one of the chapters?


#48

Sorry, It’s my typo. I mean the error that is thrown from Auth.currentSession() is a string type. Is it the Amplify creators’ intention?


#49

I’m not sure if it is but the errors aren’t really standardized. :frowning:


#50

Can I refactor the code to make the confirmation code form be shared with the sign in page? because the user might not verify the account on sign up,(he might of refreshed the page on confirmation page and lost the page), and when he try to sign in, if the account is not confirmed yet he will be able to submit the code again.

Another issue would be how to handle the refresh part on the confirmation page, i did not get that?


#51

We briefly talk about that in the chapter.

  1. Check for the UsernameExistsException in the handleSubmit method’s catch block.
  2. Use the Auth.resendSignUp() method to resend the code if the user has not been previously confirmed. Here is a link to the Amplify API docs.
  3. Confirm the code just as we did before.

So basically let it fail and then resend the code from before.


#52

How about the form that user is suppose to fill? Its disappearing if a refresh happens, so i want the user to be able to fill once they tried to sign in, i understand how to resend the code, but its where to fill the next time?

Kind regards,
Khaled


#53

It’s pretty much the same flow as before, after you call resendSignUp() you show the form to input the code.