Skip to content
This repository was archived by the owner on May 13, 2023. It is now read-only.

fix: going back to using auth headers for SupabaseQueryBuilder - #192

Merged
dshukertjr merged 5 commits into
mainfrom
fix/auth-header
Apr 30, 2023
Merged

dshukertjr merged 5 commits into
mainfrom
fix/auth-header

Conversation

@dshukertjr

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Currently, when user performs an query right after signing in, the query is performed with the session prior to signing in, resulting in empty query result. This PR fixes that.

await client.auth.signInWithPassword(email: email, password: password);

/// Unable to retrieve data if the data is protected with RLS
final data = await client
    .from('profiles')
    .select()
    .eq('user_id', response.user?.id);

Fixes supabase/supabase-flutter#456

@dshukertjr dshukertjr changed the title going back to using auth headers for SupabaseQueryBuilder fix: going back to using auth headers for SupabaseQueryBuilder Apr 28, 2023
Comment thread lib/src/supabase_client.dart Resolved
@dshukertjr
dshukertjr requested review from Vinzent03 and bdlukaa April 28, 2023 16:22
Comment thread lib/src/supabase_client.dart Resolved
@bdlukaa

bdlukaa commented Apr 28, 2023

Copy link
Copy Markdown
Contributor

Can't we have both auth and other headers?

Comment thread lib/src/supabase_client.dart Resolved
@Vinzent03

Copy link
Copy Markdown
Contributor

The problem itself though persists with storage and functions client. I think a possibility is making the onAuthStateChanged stream sync, so that the listener is instantly called. I think that would be fine with our own listener, but I don't know the consequences for the listeners in the users application. Maybe we add two streams? One async and one sync?

@dshukertjr

dshukertjr commented Apr 29, 2023 •

Copy link
Copy Markdown
Member Author

@Vinzent03
Although the problem persists with storage and functions client, the postgrest client is by far the most commonly used right after sining in. Let's ship a fix for this particular use case and discuss how to properly handle it for storage and functions client.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sometimes requires two queries to Profile table

3 participants