LCOV - code coverage report
Current view: top level - auth/middleware - get_providers_for_email_middleware.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 11 12 91.7 %
Date: 2022-03-03 12:16:56 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:firebase_auth/firebase_auth.dart';
       2             : import 'package:redux/redux.dart';
       3             : 
       4             : import '../../../types.dart';
       5             : import '../../redux/extensions/store_extensions.dart';
       6             : import '../../utils/red_fire_locator.dart';
       7             : import '../actions/email/get_providers_for_email_action.dart';
       8             : import '../actions/email/set_email_action.dart';
       9             : import '../actions/email/set_providers_for_email_action.dart';
      10             : 
      11             : ///
      12             : /// - set the email & EmailSignInStep(checking email)
      13             : /// - get & set the set of providers already assocaited with the given email
      14             : /// - set the EmailSignInStep(waiting for signin / signup)
      15             : class GetProvidersForEmailMiddleware<T extends RedFireState>
      16             :     extends TypedMiddleware<T, GetProvidersForEmailAction> {
      17           1 :   GetProvidersForEmailMiddleware()
      18           2 :       : super((store, action, next) async {
      19           1 :           next(action);
      20             : 
      21             :           try {
      22           1 :             final service = RedFireLocator.getAuthService();
      23             : 
      24           3 :             store.dispatch(SetEmailAction(action.email));
      25             : 
      26           2 :             final providers = await service.retrieveProvidersFor(action.email);
      27             : 
      28           0 :             store.dispatch(SetProvidersForEmailAction(providers));
      29             :           } catch (error, trace) {
      30           1 :             if (error is FirebaseAuthException &&
      31           2 :                 error.code == 'invalid-email') {
      32           1 :               store.dispatch(const SetEmailAction(null));
      33           1 :               RedFireLocator.getEmailTextFieldController()?.text = '';
      34             :             }
      35           1 :             store.dispatchProblem(error, trace);
      36             :           }
      37             :         });
      38             : }

Generated by: LCOV version 1.13