logInByPassword method
Implementation
Future<Either<Failure, AuthenticationInfoEntity>> logInByPassword(
LoginByPasswordRequest loginByPasswordRequest,
) async =>
request<AuthenticationInfoEntity>(
() async {
final LoginResponse response =
await loginRemoteDataSource.loginByPassword(
loginByPasswordRequest,
);
final AuthenticationInfoEntity authInfoEntity =
LoginByPasswordMapper.fromResponse(
response: response,
);
if (authInfoEntity.isSalesRep) {
await tokenLocalDataSource
.writeSalesRepToken(authInfoEntity.token!);
_controller.add(AuthenticationStatus.salesRepClientAuthenticated);
} else {
_controller.add(AuthenticationStatus.authenticated);
}
await tokenLocalDataSource.writeToken(authInfoEntity.token!);
return authInfoEntity;
},
);