Auth0 Home Blog Docs

Verification Email missing user_metadata

signup

#1

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.


#2

Anyone have any suggestions?


#3

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


#4

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


#5

@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.


#6

@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


#7

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:

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

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


#8

@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 ?