supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
656 stars 154 forks source link

`passwordRecovery` event not triggered when AppLinks stream listener is registered #943

Closed ReazerDev closed 1 week ago

ReazerDev commented 1 week ago

Describe the bug When a listener for AppLinks' uriLinkStream stream has been registered, onAuthStateChange won't emit a passwordRecovery event.

To Reproduce Steps to reproduce the behavior:

  1. Register a listener for uriLinkStream:
    AppLinks().uriLinkStream.listen((uri) {
    print(uri);
    });
  2. Register a listener for onAuthStateChange:
    Supabase.instance.client.auth.onAuthStateChange.listen((data) {
    print(data.event);
    });
  3. Open up a link containing a code query param (I'm using an iOS simulator): /usr/bin/xcrun simctl openurl booted "URL/?code=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  4. onAuthStateChange won't print the passwordRecovery event.
  5. Remove uriLinkStream added in Step 1, restart app and repeat step 3.
  6. onAuthStateChange now prints the passwordRecovery event.

Expected behavior onAuthStateChange should always trigger when a passwordRecovery URL is being opened in the app

Version (please complete the following information):

├── supabase_flutter 2.5.3
│   ├── supabase 2.1.3
│   │   ├── functions_client 2.2.0
│   │   ├── gotrue 2.7.0
│   │   ├── postgrest 2.1.2
│   │   ├── realtime_client 2.0.4
│   │   ├── storage_client 2.0.1

Additional context I tried registering the listeners in different orders, (AppLinks before Supabase, Supabase before AppLinks), but it didn't change anything. InitialAppLinks works as expected, the issue only occurs when the app is already running.

dshukertjr commented 1 week ago

I believe this is how app_link works. You can call the supabase.auth.getSessionFromUrl() method by yourself within the app_link callback if you require using app_link in your app.