Amazon-cognito-identity-js: Confirmation link code

Created on 14 Jun 2016  路  7Comments  路  Source: amazon-archives/amazon-cognito-identity-js

Is there a way quick way to directly call the cognitoUser.confirmRegistration function from a URL rather than having the user manually input a 6-digit code? I want to send my new users a "confirm" button directly in their email. Just curious if I will need to generate my own custom URL for my app and pull email/code info from that or if it's already implemented by cognito somewhere.

Most helpful comment

Would it be possible to include additional variables in the body of an activation email?

I was thinking that it may be possible to activate users automatically if the message included a redirect url with query parameters: email and code.

For example:
http://localhost:3000/activate?email={email}&code={####}

I think it's definitely a nice to have feature. Personally, I think it would be cool to have access to user attributes to add a more personal flair to each email.

All 7 comments

Currently it is not implemented by Cognito but we will consider adding this in our upcoming releases.

Ok thats understandable. Another issue I am having with the confirmation code is that it sends the same exact email whether the user created a new account or forgot a password. Is there a way to customize this email based on which situation the verification is being sent?

Currently it can be accomplished with custom message lambda trigger. See the doc and example for it here. Again providing this kind of in-built customization is something we can consider in our feature backlog.

Thanks. And yes, I personally think that those would be amazing features!

Would it be possible to include additional variables in the body of an activation email?

I was thinking that it may be possible to activate users automatically if the message included a redirect url with query parameters: email and code.

For example:
http://localhost:3000/activate?email={email}&code={####}

I think it's definitely a nice to have feature. Personally, I think it would be cool to have access to user attributes to add a more personal flair to each email.

In Lambda function you could access event.userName

@HarveyAtwal Sorry I'm super late to the game here, in the AWS Cognito Developer Guide we're given this example event parameter:

{
  "version": 1,
  "triggerSource": "CustomMessage_SignUp/CustomMessage_ResendCode/CustomMessage_ForgotPassword/CustomMessage_VerifyUserAttribute",
  "region": "<region>",
  "userPoolId": "<userPoolId>",
  "userName": "<userName>",
  "callerContext": {
      "awsSdk": "<calling aws sdk with version>",
      "clientId": "<apps client id>",
      ...
  },
  "request": {
      "userAttributes": {
          "phone_number_verified": false,
          "email_verified": true,
           ...
      },
      "codeParameter": "####"
  },
  "response": {
      "smsMessage": "<custom message to be sent in the message with code parameter>"
      "emailMessage": "<custom message to be sent in the message with code parameter>"
      "emailSubject": "<custom email subject>"
  }
}

Any of this stuff is fair game; we use it to build a one-click confirmation link in our custom message.

Was this page helpful?
0 / 5 - 0 ratings