Problem statement
Passwordless emails do not display text related to the metadata that is being set in Actions for a first time user.
Symptoms
- Using Actions to set user metadata.
- Passwordless email template relies upon metadata to populate text.
Cause
Actions run after authentication, so at the point metadata is added to the user profile, the email has already been sent and does not have access to the metadata yet.
- See Login Flow for more details.
Solution
To have a Passwordless account reliably have metadata in place when sending the Passwordless login email to a first-time user, the metadata must be in place before the user attempts to authenticate.
- The user must be created via the Management API with the relevant metadata (the /passwordless/start endpoint does not support metadata input: See Get Code or Link for more details.)
- Otherwise, the first time the email is sent, no metadata will be available for the email template.
If creating users by the Management API is impractical, the email template must have fallback values for the user’s first-time login when no metadata is available.
e.g.
{{ user.user_metadata.custom_attribute_name | default: "Default value here" }}
See here for more details on liquid syntax in email templates: