Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [firebase_ui_auth] EmailVerifiedAction can't trigger callback after verify email #221

Open
1 task done
Trung15010802 opened this issue Dec 21, 2023 · 20 comments
Open
1 task done
Labels
auth bug Something isn't working

Comments

@Trung15010802
Copy link

Trung15010802 commented Dec 21, 2023

Is there an existing issue for this?

  • I have searched the existing issues and found no duplicates.

What plugin is this bug for?

Firebase UI Auth

What platform(s) does this bug affect?

Android

List of dependencies used.

flutter pub deps -s list
dependencies:
- flutter 0.0.0
  - characters 1.3.0
  - collection 1.18.0
  - material_color_utilities 0.5.0
  - meta 1.10.0
  - vector_math 2.1.4
  - web 0.3.0
  - sky_engine any
- cupertino_icons 1.0.6
- flutter_svg 2.0.9
  - flutter any
  - vector_graphics ^1.1.9+1
  - vector_graphics_codec ^1.1.9+1
  - vector_graphics_compiler ^1.1.9+1
- change_app_package_name 1.1.0
- firebase_core 2.24.2
  - firebase_core_platform_interface ^5.0.0
  - firebase_core_web ^2.10.0
  - flutter any
  - meta ^1.8.0
- firebase_ui_auth 1.11.0
  - email_validator ^2.1.17
  - firebase_auth ^4.15.0
  - firebase_core ^2.24.0
  - firebase_dynamic_links ^5.4.6
  - firebase_ui_localizations ^1.9.0
  - firebase_ui_oauth ^1.4.15
  - firebase_ui_shared ^1.4.1
  - flutter any
  - flutter_localizations any
  - meta ^1.10.0
- firebase_auth 4.15.3
  - firebase_auth_platform_interface ^7.0.9
  - firebase_auth_web ^5.8.12
  - firebase_core ^2.24.2
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - meta ^1.8.0
- google_sign_in 6.2.1
  - flutter any
  - google_sign_in_android ^6.1.0
  - google_sign_in_ios ^5.7.0
  - google_sign_in_platform_interface ^2.4.0
  - google_sign_in_web ^0.12.0
- firebase_ui_oauth_google 1.2.15
  - firebase_auth ^4.15.0
  - firebase_ui_oauth ^1.4.15
  - flutter any
  - google_sign_in ^6.1.6
- flutter_riverpod 2.4.9
  - collection ^1.15.0
  - flutter any
  - meta ^1.4.0
  - riverpod 2.4.9
  - state_notifier >=0.7.2 <2.0.0

dev dependencies:

  • flutter_test 0.0.0
    • flutter any
    • test_api 0.6.1
    • matcher 0.12.16
    • path 1.8.3
    • fake_async 1.3.1
    • clock 1.1.1
    • stack_trace 1.11.1
    • vector_math 2.1.4
    • async 2.11.0
    • boolean_selector 2.1.1
    • characters 1.3.0
    • collection 1.18.0
    • material_color_utilities 0.5.0
    • meta 1.10.0
    • source_span 1.10.0
    • stream_channel 2.1.2
    • string_scanner 1.2.0
    • term_glyph 1.2.1
    • web 0.3.0
  • flutter_lints 3.0.1
    • lints ^3.0.0

transitive dependencies:

  • _flutterfire_internals 1.3.16
    • collection ^1.0.0
    • firebase_core ^2.24.2
    • firebase_core_platform_interface ^5.0.0
    • flutter any
    • meta ^1.8.0
  • args 2.4.2
  • async 2.11.0
    • collection ^1.15.0
    • meta ^1.1.7
  • boolean_selector 2.1.1
    • source_span ^1.8.0
    • string_scanner ^1.1.0
  • characters 1.3.0
  • clock 1.1.1
  • collection 1.18.0
  • crypto 3.0.3
    • typed_data ^1.3.0
  • desktop_webview_auth 0.0.14
    • crypto ^3.0.3
    • flutter any
    • http ^1.0.0
    • flutter_web_plugins any
    • plugin_platform_interface ^2.1.4
  • email_validator 2.1.17
  • fake_async 1.3.1
    • clock ^1.1.0
    • collection ^1.15.0
  • firebase_auth_platform_interface 7.0.9
    • _flutterfire_internals ^1.3.16
    • collection ^1.16.0
    • firebase_core ^2.24.2
    • flutter any
    • meta ^1.8.0
    • plugin_platform_interface ^2.1.3
  • firebase_auth_web 5.8.12
    • firebase_auth_platform_interface ^7.0.9
    • firebase_core ^2.24.2
    • firebase_core_web ^2.10.0
    • flutter any
    • flutter_web_plugins any
    • http_parser ^4.0.0
    • js ^0.6.3
    • meta ^1.8.0
  • firebase_core_platform_interface 5.0.0
    • collection ^1.0.0
    • flutter any
    • flutter_test any
    • meta ^1.8.0
    • plugin_platform_interface ^2.1.3
  • firebase_core_web 2.10.0
    • firebase_core_platform_interface ^5.0.0
    • flutter any
    • flutter_web_plugins any
    • js ^0.6.3
    • meta ^1.8.0
  • firebase_dynamic_links 5.4.8
    • firebase_core ^2.24.2
    • firebase_core_platform_interface ^5.0.0
    • firebase_dynamic_links_platform_interface ^0.2.6+16
    • flutter any
    • meta ^1.8.0
    • plugin_platform_interface ^2.1.3
  • firebase_dynamic_links_platform_interface 0.2.6+16
    • _flutterfire_internals ^1.3.16
    • firebase_core ^2.24.2
    • flutter any
    • meta ^1.8.0
    • plugin_platform_interface ^2.1.3
  • firebase_ui_localizations 1.9.0
    • flutter any
    • flutter_localizations any
    • path ^1.8.3
  • firebase_ui_oauth 1.4.15
    • desktop_webview_auth ^0.0.14
    • firebase_auth ^4.15.0
    • firebase_ui_auth ^1.11.0
    • firebase_ui_shared ^1.4.1
    • flutter_svg ^2.0.9
    • flutter any
  • firebase_ui_shared 1.4.1
    • flutter any
  • flutter_localizations 0.0.0
    • flutter any
    • intl 0.18.1
    • characters 1.3.0
    • clock 1.1.1
    • collection 1.18.0
    • material_color_utilities 0.5.0
    • meta 1.10.0
    • path 1.8.3
    • vector_math 2.1.4
    • web 0.3.0
  • flutter_web_plugins 0.0.0
    • flutter any
    • characters 1.3.0
    • collection 1.18.0
    • material_color_utilities 0.5.0
    • meta 1.10.0
    • vector_math 2.1.4
    • web 0.3.0
  • google_identity_services_web 0.3.0+2
    • meta ^1.3.0
    • web >=0.3.0 <0.5.0
  • google_sign_in_android 6.1.20
    • flutter any
    • google_sign_in_platform_interface ^2.2.0
  • google_sign_in_ios 5.7.1
    • flutter any
    • google_sign_in_platform_interface ^2.2.0
  • google_sign_in_platform_interface 2.4.3
    • flutter any
    • plugin_platform_interface ^2.1.0
  • google_sign_in_web 0.12.3+1
    • flutter any
    • flutter_web_plugins any
    • google_identity_services_web ^0.3.0
    • google_sign_in_platform_interface ^2.4.0
    • http >=0.13.0 <2.0.0
    • web >=0.3.0 <0.5.0
  • http 1.1.2
    • async ^2.5.0
    • http_parser ^4.0.0
    • meta ^1.3.0
    • web >=0.3.0 <0.5.0
  • http_parser 4.0.2
    • collection ^1.15.0
    • source_span ^1.8.0
    • string_scanner ^1.1.0
    • typed_data ^1.3.0
  • intl 0.18.1
    • clock ^1.1.0
    • meta ^1.0.2
    • path ^1.8.0
  • js 0.6.7
    • meta ^1.7.0
  • lints 3.0.0
  • matcher 0.12.16
    • async ^2.10.0
    • meta ^1.8.0
    • stack_trace ^1.10.0
    • term_glyph ^1.2.0
    • test_api >=0.5.0 <0.7.0
  • material_color_utilities 0.5.0
    • collection ^1.15.0
  • meta 1.10.0
  • path 1.8.3
  • path_parsing 1.0.1
    • vector_math ^2.1.0
    • meta ^1.3.0
  • petitparser 6.0.2
    • meta ^1.9.0
  • plugin_platform_interface 2.1.7
    • meta ^1.3.0
  • riverpod 2.4.9
    • meta ^1.9.0
    • stack_trace ^1.10.0
    • state_notifier >=0.7.2 <2.0.0
  • sky_engine 0.0.99
  • source_span 1.10.0
    • collection ^1.15.0
    • path ^1.8.0
    • term_glyph ^1.2.0
  • stack_trace 1.11.1
    • path ^1.8.0
  • state_notifier 1.0.0
    • meta ^1.1.8
  • stream_channel 2.1.2
    • async ^2.5.0
  • string_scanner 1.2.0
    • source_span ^1.8.0
  • term_glyph 1.2.1
  • test_api 0.6.1
    • async ^2.5.0
    • boolean_selector ^2.1.0
    • collection ^1.15.0
    • meta ^1.3.0
    • source_span ^1.8.0
    • stack_trace ^1.10.0
    • stream_channel ^2.1.0
    • string_scanner ^1.1.0
    • term_glyph ^1.2.0
  • typed_data 1.3.2
    • collection ^1.15.0
  • vector_graphics 1.1.9+1
    • flutter any
    • vector_graphics_codec 1.1.9+1
  • vector_graphics_codec 1.1.9+1
  • vector_graphics_compiler 1.1.9+1
    • args ^2.3.0
    • meta ^1.7.0
    • path_parsing ^1.0.1
    • xml ^6.3.0
    • vector_graphics_codec 1.1.9+1
    • path ^1.8.0
  • vector_math 2.1.4
  • web 0.3.0
  • xml 6.5.0
    • collection ^1.18.0
    • meta ^1.9.0
    • petitparser ^6.0.0

Steps to reproduce

Steps to Reproduce:

  1. Log in with an unverified email account.
 AuthStateChangeAction<SignedIn>(
          (context, state) {
            if (!state.user!.emailVerified) {
              Navigator.pushNamed(context, RouteName.verifyEmail);
            }
          },
        ),
  1. Navigate to the email verification page.
  2. Verify the email.
class EmailConfirmScreen extends StatelessWidget {
  const EmailConfirmScreen({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return EmailVerificationScreen(
      actions: [
        EmailVerifiedAction(
          () {
            debugPrint('EmailVerifiedAction called');

            Navigator.pushReplacementNamed(context, RouteName.authGate);
          },
        ),
        AuthCancelledAction(
          (context) {
            Navigator.pop(context);
          },
        )
      ],
    );
  }
}

  1. Despite email verification, the loading icon still appears.

Expected Behavior

Should trigger EmailVerifiedAction callback or show some UI to trigger it

Actual Behavior

infinity loading indicator

Additional Information

image
image

@Trung15010802 Trung15010802 changed the title 馃悰 [firebase_ui_auth] 馃悰 [firebase_ui_auth] EmailVerifiedAction can't trigger callback after verify email Dec 21, 2023
@danagbemava-nc
Copy link
Contributor

danagbemava-nc commented Dec 22, 2023

Hi @Trung15010802, Do you experience this same issue with the plugin example app?

I just ran the plugin example app and when I verified the email and returned to the app, I was directed to the profile page.

@danagbemava-nc danagbemava-nc added the blocked: customer response Waiting for customer response, e.g. more information was requested. label Dec 22, 2023
@Trung15010802
Copy link
Author

Trung15010802 commented Dec 22, 2023

Hi @Trung15010802, Do you experience this same issue with the plugin example app?

I just ran the plugin example app and when I verified the email and returned to the app, I was directed to the profile page.

I did almost the same as the example app but I didn't use actionCodeSettings. Does that make a difference?
As i know, the dynamic link will not available after 2025 so i didn't use it

@tahamaddam
Copy link

I experienced the same issue. A workaround is to develop your own email verification screen using StreamBuilder that listens to FirebaseAuth.instance.userChanges() stream. As soon as the email is verified (snapshot.data!.emailVerified), you can navigate the user to your desired location in the app.

@danagbemava-nc
Copy link
Contributor

I did almost the same as the example app but I didn't use actionCodeSettings. Does that make a difference?

I don't think it should, does it work if you configure actionCodeSettings?

@Trung15010802
Copy link
Author

I experienced the same issue. A workaround is to develop your own email verification screen using StreamBuilder that listens to FirebaseAuth.instance.userChanges() stream. As soon as the email is verified (snapshot.data!.emailVerified), you can navigate the user to your desired location in the app.

Events are fired when the following occurs:

  • Right after the listener has been registered.
  • When a user is signed in.
  • When the current user is signed out.
  • When there is a change in the current user's token.
  • When the following methods provided by FirebaseAuth.instance.currentUser are called:
    reload()
    unlink()
    updateEmail()
    updatePassword()
    updatePhoneNumber()
    updateProfile()

As flutter documentation said, I don't see if emailVerified event

@tahamaddam
Copy link

When there is a change in the current user's token.

More on this here

@danagbemava-nc
Copy link
Contributor

Hi @Trung15010802, if you configure your AuthStateChangeAction like below, does it work?

AuthStateChangeAction((context, state) {
                final user = switch (state) {
                  SignedIn(user: final user) => user,
                  CredentialLinked(user: final user) => user,
                  UserCreated(credential: final cred) => cred.user,
                  _ => null,
                };

                switch (user) {
                  case User(emailVerified: true):
                    Navigator.pushReplacementNamed(context, '/profile');
                  case User(emailVerified: false, email: final String _):
                    Navigator.pushNamed(context, '/verify-email');
                }
              }),

@Trung15010802
Copy link
Author

Hi @Trung15010802, if you configure your AuthStateChangeAction like below, does it work?

AuthStateChangeAction((context, state) {
                final user = switch (state) {
                  SignedIn(user: final user) => user,
                  CredentialLinked(user: final user) => user,
                  UserCreated(credential: final cred) => cred.user,
                  _ => null,
                };

                switch (user) {
                  case User(emailVerified: true):
                    Navigator.pushReplacementNamed(context, '/profile');
                  case User(emailVerified: false, email: final String _):
                    Navigator.pushNamed(context, '/verify-email');
                }
              }),

Thank you for your support. But it's doesn't work for me.

@danagbemava-nc
Copy link
Contributor

Hi @Trung15010802, could you please provide a complete minimal reproducible code sample in a repo that we can clone so that we can investigate this?

Thank you

@Trung15010802
Copy link
Author

Hi @danagbemava-nc
Here is my source code. Very simple
lib.zip

@danagbemava-nc
Copy link
Contributor

Hi @tahamaddam, using your code sample, after returning to the app from verifying my email, the app properly redirects me to the home page.

How is your firebase project configured?

@tahamaddam
Copy link

Hi @tahamaddam, using your code sample, after returning to the app from verifying my email, the app properly redirects me to the home page.

How is your firebase project configured?

Was this message for me? @danagbemava-nc

@utsavDave97
Copy link

Facing similar issue in iOS and I am running example code btw.
ezgif com-video-to-gif-converter

@danagbemava-nc
Copy link
Contributor

danagbemava-nc commented Jan 8, 2024

Was this message for me? @danagbemava-nc

Sorry @tahamaddam, it was for @Trung15010802

@utsavDave97, can you test on a physical device to see if you still get this issue?

@Trung15010802
Copy link
Author

Trung15010802 commented Jan 8, 2024

Was this message for me? @danagbemava-nc

Sorry @tahamaddam, it was for @Trung15010802

@utsavDave97, can you test on a physical device to see if you still get this issue?

Yes i have already tested in real device. I configure firebase like this tutorial
https://firebase.google.com/docs/flutter/setup?hl=vi&platform=ios

@danagbemava-nc
Copy link
Contributor

Labeling for further investigation as I cannot reproduce this locally

cc @lesnitsky, maybe you can offer some insight as to why this is happening

@danagbemava-nc danagbemava-nc added bug Something isn't working auth and removed blocked: customer response Waiting for customer response, e.g. more information was requested. in triage labels Jan 9, 2024
@stact
Copy link

stact commented Jan 14, 2024

Does this method will still work after Firebase Dynamic Links deprecation in August 2025? Maybe this part must be reviewed / refactored.

ActionCodeSettings has no more sense.

https://firebase.google.com/support/dynamic-links-faq

FYI @danagbemava-nc

@stact
Copy link

stact commented Jan 14, 2024

Working on my side too, maybe it's something related to Firebase config, did you put the right SHA related to your build on Firebase?

@timeuser
Copy link

timeuser commented Jan 21, 2024

In my case, if you don't leave the app the verification never happens. You have to leave the app and re-open it.

Example:

  1. Register a new account
  2. Email verification screen comes up showing spinner and waiting for verification
  3. I check email on my laptop and verify the email address
  4. Email verification screen still just sits there on my phone spinning indefinitely
  5. I exit the app and re-open it and verification screen closes

Perhaps this isn't a common flow a real user would go through as they would check their email from the same device. But as a developer building on a simulator or test devices I don't necessarily have email access on the same device. This is the most likely flow I hit the first time I tried and it took me a while to realize what was going on.

@KunalNestFuel
Copy link

Hi ,
I am facing the same issue while using web version in mobile chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants