fireship-io / flutter-firebase-quizapp-course

QuizApp Built with Flutter & Firebase
https://fireship.io/courses/flutter-firebase/
563 stars 242 forks source link

Infinte loading for user that's logged out. #13

Open maletor opened 4 years ago

maletor commented 4 years ago

In https://github.com/fireship-io/flutter-firebase-quizapp-course/blob/master/lib/screens/profile.dart

if the user logs out, out of band, like by resetting their password, and they are logged into the app, they'll get an infinite loading screen.

alariad commented 4 years ago

hello Maletor I have the same problem. did you find a way to make the app work?

JeanLuizds commented 4 years ago

Hello, Try to put this inside the button code:

try Auth.auth().signOut() navigationController?.popToRootViewControler(animated: true)

Joshfindit commented 2 years ago

I added this var user = FirebaseAuth.instance.currentUser;

And this to class AuthService:

Future<void> signOut() async {
    try {
      await FirebaseAuth.instance.signOut();
    } on FirebaseAuthException catch (e) {
      // Force signout anyways
      user = null;
    }
  }
}

This to Future<void> googleLogin() async {

    } on FirebaseAuthException catch (e) {
      // handle error
      user = null;
    }

Not elegant, but this course is my first dive in to Flutter and local Firebase auth

Joshfindit commented 2 years ago

I also feel like the right option is in watching the auth stream for changes and logging the user out in response, but that's above my current knowledge.