Read the profile
getUser asks the server; the session’s user is a cached copy that can be a few minutes old.
Update it
data is merged into user_metadata: only the keys you send change. A successful update fires USER_UPDATED, so components listening with onAuthStateChange refresh themselves. The server event is user.updated.
Attributes you marked admin-only in Attributes can’t be changed by the person.
Two kinds of custom data
Never base access on
user_metadata.
An avatar
Send the picture to Pawabase and it does the rest: it stores the image in a publicavatars bucket (made for you the first time, if the environment has none), points avatar_url at it, and removes the previous picture.
415, a file that is too large is 413, and the bucket also checks what the file really is, not only what it is called. Pictures are served from the gateway with no key, so an <img src={user.avatar_url}> just works. A sign-in with Google or GitHub still fills avatar_url with the provider’s picture until the person uploads their own; a picture you did not upload is never deleted.
An administrator can do the same for anyone with the secret key: PUT or DELETE /admin/v1/envs/{env}/users/{id}/avatar.
Where pictures live, and changing it
The bucket is a normal storage bucket, so you can open it in Studio and change its size limit, image types or caching, or rename it. Only the server writes to it: its write policy isservice, so your app cannot upload there directly and one person cannot overwrite another’s picture. Reads are public.
Three settings under the environment’s auth.directory.avatars control it:
Change the email
Change the password
Pass the current password with the new one (required for accounts that have one):user.password_changed fires, and the person can be emailed a safety notice (Password changed template).
A profile form
In Studio
Users → open the person → Profile. Edit name, email and username; upload or remove the picture; Public metadata and Private metadata are JSON editors.Linked accounts
Social and company identities.
Sign-up form
Collect details at sign-up.