Skip to content

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

@pappes

Description

@pappes

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)
// FirebaseExtended/flutterfire_desktop#130
// FirebaseExtended/flutterfire_desktop#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('/');
            }),
          ],
        );
      },
    ),
      ];*/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions