Open matart15 opened 2 days ago
For now I am owerwriting db_pre_request
function like this
-- Step 2: Override the db_pre_request function
create or REPLACE FUNCTION public.db_pre_request () returns void language plpgsql stable security definer
set
search_path = public as $$
declare
groups jsonb;
default_group_id uuid;
begin
-- get current groups from auth.users
select raw_app_meta_data->'groups' from auth.users into groups where id = auth.uid();
-- Check if groups is null or empty, and set to empty array if true
if groups is null or groups = '[]'::jsonb then
groups := '[]'::jsonb; -- set to empty JSON array
end if;
-- store it in the request object
perform set_config('request.groups'::text, groups::text, false /* applies to transaction if true, session if false */);
end;
$$;
Problem
I want to use supabase built in email_confirmation + phone_confirmation So i allowed my users to call signup function from frontend
Flow is
Supabase signup does not have option to write app_metadata https://supabase.com/docs/reference/javascript/auth-signup
Because app_metadata should be edited by admins
This creates user with no group data. which is fine. my app will treat that user as a general group user. ( user without group )
But this line try to read group field into
request.groups
then later try to use that as json which results error
invalid input syntax for type json
.I tried this
which results
request.groups: asdf_222
is not printedlooks like it save empty string in
request.groups (empty string): t
Question
How this library intend to use groupless users or supabase built in signup function?