Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update user metadata - Netlify Identity #44

Closed
sidati opened this issue Feb 14, 2019 · 4 comments
Closed

Update user metadata - Netlify Identity #44

sidati opened this issue Feb 14, 2019 · 4 comments

Comments

@sidati
Copy link

sidati commented Feb 14, 2019

Hi Guys,
Im trying to give my users the ability to update there meta data such as full name and phone number, it is possible to create the meta data using signup action but update them is not possible, i can only update the password and the email, is that an expected behavior or am i doing something wrong ? Hope someone can help 🤓

@bcomnes
Copy link
Contributor

bcomnes commented Feb 14, 2019

You can update the user metadata client side. App metadata has to be updated from a secure environment like a lambda function. See https://github.com/futuregerald/identity-test-functions for an example.

@bcomnes bcomnes closed this as completed Feb 14, 2019
@smuriu
Copy link

smuriu commented Aug 14, 2019

The API documentation is incomplete. To successfully write user metadata, submit a request with the user_metadata key if using the admin api, or the data key as described in the docs for the user api. Please see companion gotrue issue #213.

@tjbo
Copy link

tjbo commented Nov 11, 2020

^ Agreed, the docs are total trash.

@ecupaio
Copy link

ecupaio commented Apr 21, 2022

So I figured out how to do this with some trial and error and of course no help from the docs. For context, I'm adding a full_name field to the meta data. I'm assuming you have a basic grasp of consts and JSON but please reach out if you need a more detailed example that actually works with a form.

auth
  .signup(email, password, {full_name: fullName})
  .then((response) => {
    setFormStatus('success');
  })
  .catch((error) => {
    console.log('email state: '+email);
  });

First, pass the email and password values into the the signup function, then add your user_metadata object: {full_name: fullName} You don't need to wrap the custom metadata object in the parent user_metadata. It automatically assumes that's what you're passing through via undocumented Javascript magic. Now that custom user metadata won't actually show in Netlify Identity UI, but rest assured that data value will be stored within the user_metadata object for retrieval in your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants