Line data Source code
1 : import 'package:redux/redux.dart';
2 :
3 : import '../../../types.dart';
4 : import '../../redux/extensions/store_extensions.dart';
5 : import '../../utils/red_fire_locator.dart';
6 : import '../actions/set_auth_step_action.dart';
7 : import '../actions/sign_out_action.dart';
8 :
9 : class SignOutMiddleware<T extends RedFireState>
10 : extends TypedMiddleware<T, SignOutAction> {
11 1 : SignOutMiddleware()
12 2 : : super((store, action, next) async {
13 1 : next(action);
14 :
15 : try {
16 1 : final authService = RedFireLocator.getAuthService();
17 :
18 : // set the auth step and use the service to sign out
19 1 : store.dispatch(const SetAuthStepAction(AuthStepEnum.signingOut));
20 0 : await authService
21 4 : .signOut(store.state.auth.idTokenResult?.signInProvider);
22 0 : store.dispatch(
23 : const SetAuthStepAction(AuthStepEnum.waitingForInput));
24 : } catch (error, trace) {
25 1 : store.dispatchProblem(error, trace);
26 : }
27 : });
28 : }
|