How to sign up when link is used instead of verifi...
# help
h
How to sign up when link is used instead of verification code ? Hey, In the chapter https://serverless-stack.com/chapters/signup-with-aws-cognito.html, instead of confirmation code I have used confirmation link for sign up. What should be my flow of code instead of the following for the same? async function handleConfirmationSubmit(event) { event.preventDefault(); setIsLoading(true); try { await Auth.confirmSignUp(fields.email, fields.confirmationCode); await Auth.signIn(fields.email, fields.password); userHasAuthenticated(true); history.push("/"); } catch (e) { onError(e); setIsLoading(false); } }
f
Hey @heyysaiii, I’m not too familiar with Amplify. Looking at their doc, it seems they only support verification code? https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js/#confirm-sign-up
Where are you setting the verification code vs link?
h
Hey @Frank in the cognito user pool itself it’s providing an option to send either verification code or link for confirmation of user, particularly in the customise message tab ! There, I have change the option to link so, cognito is sending me a link for sign up confirmation instead of verification code !
f
Oh I see! I came across this GH issue talking about the verification link flow.
I think what the poster is asking might be similar to what you are looking for.
h
Yeah @Frank , I’m actually asking what should be the code for link verification instead await Auth.confirmSignUp(fields.email, fields.confirmationCode); As I have used link so there’s no confirmation code with me !?
f
I haven’t used confirmation link. But I’d imagine you shouldn’t need to call
Auth.confirmSignup()
anymore. When the users click on the confirmation link, you probably want to implement a callback, and redirect them to your site.
h
@Frank Actually I want to use post api in the sign up page to add the emailId in the database. So userHasAuthenticated() function is mandatory to do so, right ? So have to put the auth sign up and sign in functions to make the user authenticate ! Please enlighten how should I resolve this !?
f
@heyysaiii sorry I’m not familiar with confirmation link well enough to provide code snippet. You are right that you’d still need auth sign up and sign in functions, but
Auth.confirmSignup()
is not necessary right?
Reading this doc https://docs.aws.amazon.com/cognito/latest/developerguide/signing-up-users-in-your-app.html
The user account is confirmed and the user can sign in. If the user confirmed the user account by entering a confirmation code that was received via email or phone (SMS)—or, in the case of email, by clicking a confirmation link—that email or phone number is automatically verified. The code or link is valid for 24 hours.
Users are confirmed automatically when they click on the confirmation link, no?
h
@Frank No matter Auth.confirmSignUp() is added or not, still asking for the code as object when I’m trying to add Auth.Signup() and Auth.Signin(). And without handleConfirmation(), data can’t be sent to the db.