Can loginWithRedirect pass metadata?

I want to use the Hooks Pre User Registration feature to add metadata to both user_metadata and app_metadata.

I’m using SPA flow with loginWithRedirect to sign up a new user using New Universal Login without a custom form. Using @auth0/auth0-spa-js library.

Here’s the client side code:

loginWithRedirect({
  redirect_uri: 'http://localhost:3000/hi',
  screen_hint: 'signup',
  user_metadata: {
    birthday: '22-03-1980',
  },
  app_metadata: {
    some_id: 12345,
  },
})

Is there a way to pass data up from loginWithRedirect that may be accessible from the hook?

module.exports = function (user, context, cb) {
  var response = {};
  response.user = user;

  // How can I get data from the New Universal Login sign up form called with loginWithRedirect
  // from the @auth0/auth0-spa-js library?

  // Add user or app metadata to the newly created user
  response.user.user_metadata = { foo: 'bar' };
  response.user.app_metadata = { vip: true, score: 7 };

  cb(null, response);
};

Hi @jemery,

This isn’t possible that I know of. There may be an issue setting app_metadata this way anyways, since a user could make this request themselves and change that value to whatever they wanted.

You may be better off using a redirect from a rule or progressive profiling.

Hope this helps!
Dan

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