Editing root data on post login action

Hi,
I’m in the process of migrating our rules/hooks to the new actions / flows. We are using a rule which removes white spaces from given and family name. This works pretty well, but with the new action and flow approach, I can not find a solution for this. And: no, using our backend to edit those data via Management API is not a real solution.

What’s doable is something like this:

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

  const family_name = event.user.family_name || event.user.last_name || "anonymous";
  api.user.setAppMetadata("family_name", family_name.trim());
  
  const given_name = event.user.given_name || event.user.first_name || "anonymous";
  api.user.setAppMetadata("given_name", given_name.trim());

};

I have seen several other users here in the forum who also have to edit data in the user’s root (but for different reasons). Is this feature still to come? Or is there already a solution but I just couldn’t find it?

Hi @p.friedrich

Welcome to the Auth0 Community!

Thank you for posting your question. I would recommend using a management API inside the post-login action to make a request that would adjust the user profile. You can read more about that here → Using the Management API in Actions

Thanks
Dawid

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