loginWithEmail method
Implementation
Future<FirebaseAuthenticationResult> loginWithEmail({
required String email,
required String password,
}) async {
try {
log?.d('email:$email');
final result = await firebaseAuth.signInWithEmailAndPassword(
email: email,
password: password,
);
log?.d('Sign in with email result: ${result.credential} ${result.user}');
// Link the pending credential with the existing account
if (_pendingCredential != null) {
await result.user?.linkWithCredential(_pendingCredential!);
_clearPendingData();
}
return FirebaseAuthenticationResult(user: result.user);
} on FirebaseAuthException catch (e) {
log?.e('A firebase exception has occurred. $e');
return FirebaseAuthenticationResult.error(
exceptionCode: e.code.toLowerCase(),
errorMessage: getErrorMessageFromFirebaseException(e));
} on Exception catch (e) {
log?.e('A general exception has occurred. $e');
return FirebaseAuthenticationResult.error(
errorMessage:
'We could not log into your account at this time. Please try again.');
}
}