signInWithEmailAndPassword method

  1. @override
Future<Either<Failure, UserEntity>> signInWithEmailAndPassword(
  1. String email,
  2. String password
)
override

Implementation

@override
Future<Either<Failure, UserEntity>> signInWithEmailAndPassword(
  String email,
  String password,
) async {
  try {
    final user = await remoteDataSource.signInWithEmailAndPassword(email, password);
    await localDataSource.cacheUser(user);
    return Right(user);
  } on AuthException catch (e) {
    return Left(AuthFailure(e.message));
  } on NetworkException catch (e) {
    return Left(NetworkFailure(e.message));
  } catch (e) {
    return Left(AuthFailure('An unexpected error occurred'));
  }
}