pappes / MyMovieSearch

test android app using flutter
GNU General Public License v3.0
1 stars 0 forks source link

Configure identity for Firebase connections (email, etc) #71

Open pappes opened 11 months ago

pappes commented 11 months ago

Currently all firebase connetions are anon because flutterfire does not support linux and will fail to compile if UI screens are configured

When FirebaseIUAuth supports linux applications should set up the UI screens see https://firebase.google.com/docs/auth/android/anonymous-auth

Could be resolved when firebase_auth_desktop issue 130 is fixed via PR 131 (has been awaiting merge since 30 July 2023) // https://github.com/FirebaseExtended/flutterfire_desktop/issues/130 // https://github.com/FirebaseExtended/flutterfire_desktop/pull/131 // also https://stackoverflow.com/questions/73989832/flutterfire-cli-not-showing-windows-and-linux-as-an-option-for-platform-to-suppo

replace/extend the current code await FirebaseAuth.instance.signInAnonymously(); to include /FirebaseUIAuth.configureProviders([ EmailAuthProvider(), ]);/ and


  /// Defines known routes handled by Firebase UI.
  ///
  /*List<RouteBase> getRoutes() => [  
    GoRoute(
      path: 'sign-in',
      builder: (context, state) {
        return SignInScreen(
          actions: [
            ForgotPasswordAction((context, email) {
              final uri = Uri(
                path: '/sign-in/forgot-password',
                queryParameters: <String, String?>{
                  'email': email,
                },
              );
              context.push(uri.toString());
            }),
            AuthStateChangeAction((context, state) {
              final user = switch (state) {
                final SignedIn state => state.user,
                final UserCreated state => state.credential.user,
                _ => null
              };
              if (user == null) {
                return;
              }
              if (state is UserCreated) {
                user.updateDisplayName(user.email!.split('@')[0]);
              }
              if (!user.emailVerified) {
                user.sendEmailVerification();
                const snackBar = SnackBar(
                    content: Text(
                        'Please check your email to verify your email address'));
                ScaffoldMessenger.of(context).showSnackBar(snackBar);
              }
              context.pushReplacement('/');
            }),
          ],
        );
      },
      routes: [
        GoRoute(
          path: 'forgot-password',
          builder: (context, state) {
            final arguments = state.uri.queryParameters;
            return ForgotPasswordScreen(
              email: arguments['email'],
              headerMaxExtent: 200,
            );
          },
        ),
      ],
    ),
    GoRoute(
      path: 'profile',
      builder: (context, state) {
        return ProfileScreen(
          providers: const [],
          actions: [
            SignedOutAction((context) {
              context.pushReplacement('/');
            }),
          ],
        );
      },
    ),
      ];*/