Flow step:
- Sign in with twitter
mail@gmail.com(successfully) - Sign in with google
mail@gmail.com(successfully rewrite provider to google) - Sign in with twitter again
mail@gmail.com(failed, account already exist with different provider)
i'm so confuse in step 2.. because, firebase not blocking sign in with google provider and do rewrite provider
Future<Either<Failure, Unit>> signInWithTwitter() async {
try {
if (kIsWeb) {
await _firebaseAuth.signInWithPopup(_twitterAuthProvider);
} else {
await _firebaseAuth.signInWithProvider(_twitterAuthProvider);
}
return right(unit);
} on FirebaseAuthException catch (e) {
return left(
Failure.authFailure(
message: e.toString(),
),
);
}
}
Future<Either<Failure, Unit>> signInWithGoogle() async {
try {
final googleUser = await _googleSignIn.signIn();
if (googleUser == null) {
return left(const Failure.authFailure());
}
final googleAuthentication = await googleUser.authentication;
final authCredential = GoogleAuthProvider.credential(
idToken: googleAuthentication.idToken,
accessToken: googleAuthentication.accessToken,
);
await _firebaseAuth.signInWithCredential(authCredential);
return right(unit);
} on FirebaseAuthException catch (e) {
return left(
Failure.authFailure(
message: e.toString(),
),
);
}
}
so, How to block user sign in if account already exists with other provider (like: twitter, github, facebook etc)?