How to add username in supabase.auth.currentUser?

1.7k views Asked by At

If already authenticated, i can access and call supabase.auth.currentUser to retrieve some user data like full_name, email, avatar_url, etc.

But how to modify the data inside it?, so when i login and authenticated, i can call supabase.auth.currentUser that contains my username.

2

There are 2 answers

0
ryandra On BEST ANSWER

Maybe there is a way by modify postgresql in supabase, but i'm beginner that don't know about it.

In here i take an example data of 'username'. If i logged in, i can call supabase.auth.currentUser where saved in cache automatically. But by default there isn't username data in there.

What do i do, after login is success, i directly request again to get username data and save it in local storage using shared_preferences plugin. Then navigate to home page.

0
dshukertjr On

It is recommended to create a separate table in the public schema to store user profiles in Supabase like this:

create table public.profiles (
  id uuid not null references auth.users on delete cascade,
  first_name text,
  last_name text,

  primary key (id)
);

alter table public.profiles enable row level security;

You can read more on the managing user data guide here.