@@ -18,7 +18,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
18
18
final AuthBloc authBloc;
19
19
final AuthRepository repository;
20
20
LoginBloc ({required this .authBloc, required this .repository})
21
- : super (LoginState ()) {
21
+ : super (const LoginState ()) {
22
22
on < CreateLoginFlow > (_onCreateLoginFlow);
23
23
on < GetLoginFlow > (_onGetLoginFlow);
24
24
on < ChangeNodeValue > (_onChangeNodeValue);
@@ -33,12 +33,10 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
33
33
final loginFlow = await repository.createLoginFlow (aal: event.aal);
34
34
35
35
emit (state.copyWith (loginFlow: loginFlow, isLoading: false ));
36
- } on CustomException catch (e) {
37
- if (e case UnknownException _) {
38
- emit (state.copyWith (isLoading: false , message: e.message));
39
- } else {
40
- emit (state.copyWith (isLoading: false ));
41
- }
36
+ } on UnknownException catch (e) {
37
+ emit (state.copyWith (isLoading: false , message: e.message));
38
+ } catch (_) {
39
+ emit (state.copyWith (isLoading: false ));
42
40
}
43
41
}
44
42
@@ -48,12 +46,10 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
48
46
emit (state.copyWith (isLoading: true , message: null ));
49
47
final loginFlow = await repository.getLoginFlow (flowId: event.flowId);
50
48
emit (state.copyWith (loginFlow: loginFlow, isLoading: false ));
51
- } on CustomException catch (e) {
52
- if (e case UnknownException _) {
53
- emit (state.copyWith (isLoading: false , message: e.message));
54
- } else {
55
- emit (state.copyWith (isLoading: false ));
56
- }
49
+ } on UnknownException catch (e) {
50
+ emit (state.copyWith (isLoading: false , message: e.message));
51
+ } catch (_) {
52
+ emit (state.copyWith (isLoading: false ));
57
53
}
58
54
}
59
55
@@ -75,20 +71,18 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
75
71
value: event.value,
76
72
nodes: state.loginFlow! .ui.nodes.toList ());
77
73
authBloc.add (ChangeAuthStatus (status: AuthStatus .authenticated));
78
- } on CustomException catch (e) {
79
- if (e case BadRequestException <LoginFlow > _) {
80
- emit (state.copyWith (loginFlow: e.flow, isLoading: false ));
81
- } else if (e case UnauthorizedException _) {
82
- authBloc.add (ChangeAuthStatus (status: AuthStatus .unauthenticated));
83
- } else if (e case FlowExpiredException _) {
84
- add (GetLoginFlow (flowId: e.flowId));
85
- } else if (e case TwoFactorAuthRequiredException _) {
86
- authBloc.add (ChangeAuthStatus (status: AuthStatus .aal2Requested));
87
- } else if (e case UnknownException _) {
88
- emit (state.copyWith (isLoading: false , message: e.message));
89
- } else {
90
- emit (state.copyWith (isLoading: false ));
91
- }
74
+ } on BadRequestException <LoginFlow > catch (e) {
75
+ emit (state.copyWith (loginFlow: e.flow, isLoading: false ));
76
+ } on UnauthorizedException catch (_) {
77
+ authBloc.add (ChangeAuthStatus (status: AuthStatus .unauthenticated));
78
+ } on FlowExpiredException catch (e) {
79
+ add (GetLoginFlow (flowId: e.flowId));
80
+ } on TwoFactorAuthRequiredException catch (_) {
81
+ authBloc.add (ChangeAuthStatus (status: AuthStatus .aal2Requested));
82
+ } on UnknownException catch (e) {
83
+ emit (state.copyWith (isLoading: false , message: e.message));
84
+ } catch (_) {
85
+ emit (state.copyWith (isLoading: false ));
92
86
}
93
87
}
94
88
}
0 commit comments