signInWithEmailAndPassword method
Implementation
@override
Future<UserModel> signInWithEmailAndPassword(
String email,
String password,
) async {
try {
final userCredential = await _auth.signInWithEmailAndPassword(
email: email,
password: password,
);
final claims = await getUserClaims();
return UserModel(
uid: userCredential.user!.uid,
email: userCredential.user!.email,
username: userCredential.user!.displayName,
claims: claims,
);
} on firebase_auth.FirebaseAuthException catch (e) {
switch (e.code) {
case 'user-not-found':
throw UserNotFoundException();
case 'wrong-password':
throw InvalidCredentialsException();
case 'invalid-email':
throw InvalidEmailException();
case 'email-already-in-use':
throw EmailAlreadyInUseException();
case 'requires-recent-login':
throw RecentLoginRequiredException();
default:
throw UnknownAuthException(e.message ?? e.toString());
}
} catch (e) {
throw UnknownAuthException(e.toString());
}
}