Actions, Stripe, Logs

I want to update user metadata with stripe information when the user logs in. I know that Actions are preferred over Rules.
Can this be done from an action?
I deployed an action on login that just does a console.log. Where can I see this log? It is not in Monitoring | Logs.

Fred

Hi @ragno

Welcome to the Auth0 Community! It’s great to have you on board :slight_smile:

You can set user metadata with a post login action like this:

exports.onExecutePostLogin = async (event, api) => {
  api.user.setUserMetadata("favorite_color", "blue");
};

Please see this reference for a specific example plus lots more https://auth0.com/docs/customize/actions/triggers/post-login#enrich-the-user-profile

The console log messages can be viewed via the Real-time Webtask Logs Extension https://auth0.com/docs/customize/extensions/real-time-webtask-logs

Install it into your tenant via the Extensions menu option on the left hand side, click on the extension to fire it up, it will connect to your tenant and listen for console.logs. Trigger your Action via a login/registration etc and watch the logs roll in :slight_smile:

Let me know if you have any further questions on this.
All the best.

2 Likes

Thanks! Now how can I call to see what the userMetadata is (if it has been set, or null if not)

Hey @ragno

The user_metadata is a javascript dictionary type so you can query it as such, also you need to use the event object to get the values from it e.g.

Object.keys(event.user.user_metadata); //List all keys
event.user.user_metadata.favorite_color; //Get the value for a specific key

I hope this helps, please get back to me if you have nay further questions.
Warm regards.

2 Likes

Perfect. Thank you saqib!

-Fred

No problem, I’m glad I was able to help.

All the best.

1 Like

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