Where and how to store user_metadata

I have a question about how to enrich a user’s profile with metadata. I’m using React with a C# API. When a user signs up for the service (either with an email/password or through a provider), I’d like to extract their name and avatar and store it as metadata so that they can change it in my app without having to change it in their Google account (or wherever). The name will essentially become their display name in my app and the avatar is meant as an initial placeholder that they can change later if they choose.

I’ve seen examples of how to do this with Actions using api.user.setUserMetadata when they log in but I don’t want to do it on every login, just when they sign up. Is this just a matter of checking whether the specified user_metadata field has been set already?

I also tested the PreUserRegistration flow but that seems to be limited to Email/Password accounts and not ones from other providers.

Assuming I have a way of storing that info in user metadata, what’s the normal process for updating it with React? Should I make an API call to Auth0 directly from the appropriate page in my app or do you normally submit the info to the server and have my backend API make the request? If it’s the former, I think I’m having trouble wrapping my head around how to prevent someone submitting a request to change someone else’s account.

Hi @kyle.baley

Do it with actions, but only set the metadata if it does not exist. This will only do it once, not every login.

John

1 Like

Thanks @john.gateley. I’ll do that. What about the question about updating the user profile. Is that something that’s normally done directly from the client in React. If so, how does one prevent someone submitting an update request for a different account?

The management API is protected by an access token, just like any other API.
A user can never get an access token for a different user.

John

1 Like