emailPasswordSignIn method
returns Error message. Returns null if was successful
Implementation
@override
Future<String?> emailPasswordSignIn(LoginCredentials credentials) async {
//see https://firebase.flutter.dev/docs/auth/usage/#emailpassword-registration--sign-in
try {
UserCredential userCredential = await FirebaseAuth.instance
.signInWithEmailAndPassword(
email: credentials.email, password: credentials.password);
return null;
} on FirebaseAuthException catch (e) {
if (e.code.contains(FirebaseAuthErrorCode.wrongPassword)) {
return "Wrong password";
}
if (e.code == 'weak-password') {
return 'The password provided is too weak.';
} else if (e.code == 'email-already-in-use') {
return 'The account already exists for that email.';
} else {
return ("Failed to login");
}
} catch (e) {
return "Failed to login $e";
}
}