Supabase: How to fetch a user by email?
Self explanatory from the title.
We have
const { data: { user }, error: authError } = await supabase.auth.admin.getUserById('5d16dc00-4d1d-4026-a60a-ccf5b549da15');
Is there an equivalent for fetching the user through their email address?
Thank you.
5 Replies
No.
You could write your own Postgres function to return from auth.users a select on email column and call with RPC. Just make sure to secure it by removing grants from anon and authenticated or check for service_role in auth.jwt()->>'role'.
I will give this a go, thank you
Hmm

Nvm, permission denied for table users
Am I supposed to add the service_role for the user's table?
Solved by running:
The better way was to make the function security definer type. But that way works too.