Hi,
I just wanted to say thanks for a great package we can use to simplify authentication with. It really does make it go faster and I know I have qualified devs working on auth for/with me. Sometimes it's not an easy thing, especially when I'm new to flutter.
So my request is for the ability to override, or allow us more options/customization of SupabaseAuth. Couple things come to mind when I say this. 1. I was working through the chat app tutorial, the branch with auth, and when a user is added to the table, a trigger then adds a couple fields into the profile table. One of the things that's supposed to be added to profile's page is the username from auth.users. Well the username now comes from the raw_user_meta_data jsonb column. So the email and pass get's inserted, but no username. And there is no way to add the username to the metadata column in flutter with this package. I ended up just creating another trigger and function that add's a new username into metadata column when inserting and then taking that and inserting into the username column in the profiles page.
Here's the code to do this if anyone would be interested and came across the same issue as me. Took me a little bit to figure out how to handle the jsonb in a trigger/function like this, but did finally get it working. So the email is just used for the username as well. This function add's it into the same table but in the metadata column, and then the trigger/function from the tutorial picks that up and inserts it into the profile table along with other info.
create
or replace function handle_new_user_metadata() returns trigger as $$
begin
update auth.users
set raw_user_meta_data['username'] = to_jsonb(auth.users.email)
WHERE auth.users.id = NEW.id;
return NEW;
end;
$$ language plpgsql security definer;
DROP TRIGGER
IF EXISTS on_auth_user_created_meta ON auth.users CASCADE;
create trigger
on_auth_user_created_meta
after
insert
on auth.users for each row
execute
function handle_new_user_metadata();
It would be a lot easier though if we were able to do this from dart/flutter. I see there is already the capability in the supabase client, but we can't access it from this package. Only the email and pass can be used when calling to create a user in registration. So that would be nice to override/ or just have all 4 of the parameters that are in the supabase sdk create user method.
Second would be the navigation. I'm using riverpod and go router for my nav. Riverpod listens for auth state changes, then go router listens to riverpod to trigger it to log the user in/out according to their auth state. But then when there is code for a second navigation, it messes with the whole flow. Maybe an option to use your own router and logic, or use what's baked in?
These are just some suggestions. I love the idea of being able to quickly get auth going so I can get on with the actual business logic a client needs. You have done a wonderful job on that and just wanted to say I appreciate it a lot.