Verification Email missing user_metadata

Our team is trying to localize our email templates as suggested here:

We’ve added an auth0 rule to add the user’s language to the user_metadata upon signup, which appears to work correctly. We’ve added {% debug %} to our email templates to ensure the language is coming through successfully in the user_metadata on all our email templates which it does - except for the Verification Email.

Is user_metadata not passed in with the Verification Email? We see the user field, but not the user.user_metadata field.

Anyone have any suggestions?

We are currently investigating some of the possible ways to handle this and will get back with you with some ideas

Great thanks Jeremy! Let me know if you need any more details from our end.

@adam.rehill This is happening because rules are run during login, and the verification email is sent just after signup - rules don’t have a chance to run before that.

One option would be to set the metadata in a pre-registration hook:

The metadata you set there will be available in the verification email.

@thameera Thanks for the suggestion, this does seem to work as far as updating user_metadata before the email gets sent, however we don’t have access to the same context field as we do on rules. We are using context.request.query to access the language we tack on during signup. context.request.query is not available in the pre-registration hook.

I also tried context.requestLanguage but this seems to be the browser’s accept-language header which is not the same thing.

Any other suggestions?

Thanks

Another option would be to send the language during the signup, so it will automatically become a part of user’s user_metadata (instead of sending it via a query param).

If you’re using Auth0 Lock, this can be sent using additionalSignupFields for example:

https://auth0.com/docs/libraries/lock/v11/configuration#additionalsignupfields-array

If you use Auth0.js, this is easier, since you can pass user_metadata directly:

https://auth0.com/docs/libraries/auth0js/v9#signup

I haven’t tested this in relation to verification emails, but it should do the trick.

@thameera Why context.request.query is not accessible ? It will be so simple to get the language from the url.

In a nutshell, to set an app language to the user metadata, we are forced to add an additionnalField and implement “Progressive Profiling” for SSO (google/facebook …) ?

Any better suggestion ?

OMG. This post is exactly what I was looking for. Everything works great except the the verification email because I set the user_metadata language in a Rule, which is too late (the Verification email is sent after that). I have tried the very other things above.

@thameera I tried that last solution, but couldn’t make it work yet:
1)Passing “user_metada” is super easy with the Auth0.js, but I use Lock and the only way possible to send user_metadata is by creating an additional field ( additionalSignupFields), but this field is only for Database connections, right?
2) Hooks would help me a lot, but it only works for Database Connections: again, social connections won’t apply :confused:

My question is: How can I pass user_metadata on signup for Social connections? All solutions dont seem to work for Social Connections.

Thanks!

1 Like

@thameera We are having the exact same issue. Is there a solution to the social login issue?

Verification emails are sent only for users from database connections, not social. What exactly is the issue you are facing with social users?