The login screen now redirects to the home screen if a user successfully logs in

This commit is contained in:
Mariano Uvalle 2019-03-09 21:47:04 -06:00
parent 475b1d0bc1
commit 04288e0d15
3 changed files with 30 additions and 4 deletions

View file

@ -22,9 +22,12 @@ class AuthService {
_googleSignInProvider.onAuthStateChange.pipe(_user);
}
Future<void> googleLoginAndSignup() async {
Future<FirebaseUser> googleLoginAndSignup() async {
final user = await _googleSignInProvider.signIn();
if (user == null) {
return null;
}
// Create a new user in Firestore if this is the first time signing in.
if (!await _firestoreProvider.userExists(user.email)) {
final newUserModel = UserModel(
@ -37,6 +40,8 @@ class AuthService {
);
await _firestoreProvider.createUser(newUserModel, user.uid);
}
return user;
}
Future<void> signOut() {