Cannot set AppMetadata or UserMetaData in Passwordless flow with Pre-registration Action / Hook

Problem statement

Using extensibility to write metadata before registration with a passwordless connection doesn’t work.

Symptoms

The user is registered, and the metadata is empty.

Steps to reproduce

  • Pre-registration Action / Hook to set the metadata
  • Sign up
  • Check the user’s metadata

Troubleshooting

Check if the pre-registration Action / Hook is executed (debug with console or webhook message/log).

Cause

With Passwordless connections, it is not supported to use the pre-registration Action because it works differently than with the other connection types.

Solution

To add the metadata for this connection type, you must use a Post-Login Action. You can also add a condition to check in a Post Login Action to filter whether the connection is passwordless so it’s not executed with others by filtering the objects within the event.authentication.methods array with this structure:

[{name: "sms" | name:"email"}]