Can the email alias be referenced as a template variable in the resendConfirmationCode and forgotPassword email templates?

0

Is there a way to reference the email alias in the the email template for reset password? I am using email as an alias and generating the cognito username (guid). But when the reset password email goes out I would like it to reference the email address rather than the generated username.

To illustrate, this is how the email is generated currently as it references {username}. Your username is aVwe3uyXcc9WbmkKTbNq4i and your temporary password is 1ZVKi@ZL.

I'd like to reference the email alias. Is that variable available to the email template?

I am passing email as the "Username" parameter to both resendConfirmationCode and forgotPassword methods and in both cases the {username} parameter in the template is replaced with the guid username rather than the email alias.

asked a year ago205 views
1 Answer
0

Can you use the Custom Message Lambda for CustomMessage_ForgotPassword case and do a look up in the event.request.userAttributes for the appropriate value you need to craft your own message.

reference: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html

AWS
answered a year ago
  • Thanks Jeff. One problem I got was that if I don't have usernameParameter in my template then the CustomMessage_ForgotPassword trigger is ignored. I suppose I could hide that variable in the html but that doesn't work for anything other than HTML.

  • I just confirmed that if I hide the usernameParameter in a hidden span tag in the custom message then the custom message is sent successfully (vs the default userpool message)

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions