Updating User Profile from Actions

Hi @igelu,

Welcome to the Auth0 Community!

I understand you have questions about updating the user’s profile family_name and given_name properties using Actions.

In this situation, I recommend using the Management API in Actions to call the updateUser() method and passing the family_name and given_name properties to be updated in the user profile. I have attached the corresponding code snippet below:

exports.onExecutePostLogin = async (event, api) => {

  const ManagementClient = require('auth0').ManagementClient;

  const management = new ManagementClient({
      domain: event.secrets.domain,
      clientId: event.secrets.clientId,
      clientSecret: event.secrets.clientSecret
  });

  const params =  { id: event.user.user_id};

  const data = {
    "family_name" : "kenobi",
    "given_name" : "obiwan"
  }

  try {
    const res = await management.updateUser(params, data) 
  } catch (e) {
    console.log(e)
    // Handle error
  }
};

Moreover, I have tested this Action script and confirm that it will update the user’s family_name and given_name properties on their user profile.

I hope this helps!

Please let me know if there is anything else I can do to help.

Thank you.

2 Likes