User.user_metadata not populating in "Change Password" email template

Hello, I’ve been having some trouble with an email template. It doesn’t seem to be an issue on all of the templates, however.

I’ve got a template set up for “Change Password” emails, that attempts to lift a property from the user.user_metadata object. However, the values do not populate. I have appended a {%debug%} statement to the bottom of the e-mail template, and it confirms this.

I have verified that the user has the correct metadata property set (which is does), and I also have the exact same logic working on a “Verification Email (using Link)” template.

Is there any reason I cannot access the metadata from the “Change Password” template?

It also appears that using the Try button sends the metadata, but when an actual one is sent from my auth0 URL, then the metadata is not included.

Hi @nick.howard.lykke ,

I understand that you want to call a user.user_metadata property in the Change Password email template. I tested this by adding the property parameter as below

<p>You have submitted a password change request.{{user.user_metadata.userproperty}}</p>

, where userproperty is a property name under user_metadata. In my testing, the value saved under userproperty was populated correctly with both Try button and clicking on the forgot password link on the login page.

Could you try the above scripts and let me know how it goes? If the issue persists, please provide the scripts in your Change Password template. I am happy to look into this further.

Thanks!

Hi @lihua.zhang

Yes, you are correct.

I have updated the user_metadata on my user to have the following properties:

{
  "requestLanguage": "en,en-US;q=0.9",
  "userProperty": "test"
}

The requestLanguage is the property I have been trying to read previously, and userProperty is a new one, I have just added now.

Then in my template, I added the following at the end (before the </body> tag:

<pre>test value: {{user.user_metadata.userProperty}}</pre>
<pre>{%debug%}</pre>

The results are still the same:

When using the Try button, I get:

test value: test

When submitting the actual email, I get:

test value:

Also, when using Try, the debug of the user object includes user_metadata properties, but the actual email does not.

There looks to be a mismatch between the clientIds being used.

The user signs up with one, and has their password reset email sent using the same one… but, the Try button uses a different clientId.

So

  • user signs up - client-a with user_metadata
  • user resets password - client-a but no user_metadata
  • I use the Try button - client-b even though the connection dropdown uses the same name as client-a… this has user_metadata.

I’m really confused about this.

I’ve looked in the admin console at the user that has been created and their Authorized Applications only includes client-a.

Also, I can’t find any applications that have a clientId for client-b.

I’ve managed to locate client-b. It relates to the All Applications application. However, it doesn’t really help in this case, as it’s not something that will point to fixing my initial problem.

Could you please DM me the name of your tenant, the email of the user that you clicked on “Forgot password” to trigger the email, and the name of the application that the user tried to log in to? Thanks!

Sure thing, I’ll get it sent over to you now

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.