Mike_
12/28/2021, 4:48 PMjs
// In my case, I need to add additional users as 'owners' of a record using their email address
// Find user by email
const { data, error } = await supabase
.from('auth.users') // Not possible now
.select()
.eq('email', 'user@gmail.com')
// Then use the user's data for some business logic
Some developers have used workarounds like creating a public.users table which replicates relevant data from the auth.users table using triggers. This feels like a hacky workaround to me... I would much rather avoid this unnecessary redundancy / potential for data inconsistency down the line. (See: https://nikofischer.com/supabase-how-to-query-users-table)
Edit: I've copied this feature request to the git repo: https://github.com/supabase/supabase/issues/4715silentworks
12/29/2021, 2:05 AMsilentworks
12/29/2021, 2:07 AMMike_
12/29/2021, 6:19 PMMike_
12/29/2021, 6:21 PMMike_
12/29/2021, 6:42 PME.g. when auth.users.email changes, replicate to public.users.email
I'm still unclear about how read-only service-key-only access would add significant risk... apparently there is already an undocumented supabase.auth.api.listUsers function (https://github.com/supabase/supabase/issues/4715#issuecomment-1002213887) exposed which means that this data is already available for access with a service key...? I only suggest adding the ability to read the users table more surgically with .match filters, etc. Functionality like this would help avoid the need to learn & set up triggers / produce redundant data / increase surface area of codebase unnecessarily.HarryET
12/29/2021, 6:47 PM