Auth0 Actions: How to set user_metadata temporary betwen actions

Hi,

I have 2 actions called one after another. I am setting some data from Action 1 using

api.user.setUserMetadata('newField', 'some data');

and in Action 2 when i

console.log(event.user.user_metadata);

I get newField and this also gets saved in to actual user’s user_metadata.

Question: Is there a way to save this temporary only for the login session and not forever in user’s user_metadata?
I am trying to merge user_metadata between Social login user and auth0 user with same email on login. But i don’t want to persist that data forever. Is there a way to do that?

Thanks.

Hi @npatel,

Thanks for reaching out to the Auth0 Community!

Unfortunately, the api.user.setUserMetadata will save the users’s user_metadata forever.

As an alternative, you could consider resetting the user’s user_metadata by using the Management API update a user endpoint to programmatically reset the user_metadata based on your needs (i.e every few days). With this approach, you’ll have the flexibility to keep and discard any user_metadata values.

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

Thank you.

Ok, I just ended up moving that code of making ManagmentClient in this new action where we need the merged userMetadata so i don’t have to set it, but this is good to know in case we come across similar situation. We are trying to move our rules to actions so the difference between them keep popping up :wink:

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