@@ -7,6 +7,8 @@ import 'package:amplify_auth_cognito_dart/src/sdk/cognito_identity_provider.dart
7
7
import 'package:amplify_auth_cognito_dart/src/state/cognito_state_machine.dart' ;
8
8
import 'package:amplify_auth_cognito_dart/src/state/state.dart' ;
9
9
import 'package:amplify_core/amplify_core.dart' ;
10
+ // ignore: implementation_imports
11
+ import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart' ;
10
12
11
13
/// {@template amplify_auth_cognito.sign_up_state_machine}
12
14
/// Manages user sign up with Cognito.
@@ -34,12 +36,15 @@ final class SignUpStateMachine
34
36
return cognitoIdp;
35
37
}
36
38
37
- CognitoUserPoolConfig get _userPoolConfig {
38
- final userPoolConfig = get <CognitoUserPoolConfig >();
39
- if (userPoolConfig == null ) {
39
+ AuthOutputs get _authOutputs {
40
+ final amplifyOutputs = get <AmplifyOutputs >();
41
+ if (amplifyOutputs == null ||
42
+ amplifyOutputs.auth == null ||
43
+ amplifyOutputs.auth? .userPoolId == null ||
44
+ amplifyOutputs.auth? .userPoolClientId == null ) {
40
45
throw const InvalidAccountTypeException .noUserPool ();
41
46
}
42
- return userPoolConfig ;
47
+ return amplifyOutputs.auth ! ;
43
48
}
44
49
45
50
ASFContextDataProvider get _contextDataProvider => getOrCreate ();
@@ -78,7 +83,7 @@ final class SignUpStateMachine
78
83
SignUpRequest .build (
79
84
(b) {
80
85
b
81
- ..clientId = _userPoolConfig.appClientId
86
+ ..clientId = _authOutputs.userPoolClientId
82
87
..username = event.parameters.username
83
88
..password = event.parameters.password
84
89
..clientMetadata.addAll (event.clientMetadata)
@@ -100,11 +105,12 @@ final class SignUpStateMachine
100
105
)
101
106
..analyticsMetadata = get <AnalyticsMetadataType >()? .toBuilder ();
102
107
103
- final clientSecret = _userPoolConfig.appClientSecret;
108
+ // ignore: invalid_use_of_internal_member
109
+ final clientSecret = _authOutputs.appClientSecret;
104
110
if (clientSecret != null ) {
105
111
b.secretHash = computeSecretHash (
106
112
event.parameters.username,
107
- _userPoolConfig.appClientId ,
113
+ _authOutputs.userPoolClientId ! ,
108
114
clientSecret,
109
115
);
110
116
}
@@ -138,17 +144,18 @@ final class SignUpStateMachine
138
144
await _cognito.confirmSignUp (
139
145
ConfirmSignUpRequest .build ((b) {
140
146
b
141
- ..clientId = _userPoolConfig.appClientId
147
+ ..clientId = _authOutputs.userPoolClientId
142
148
..username = event.username
143
149
..confirmationCode = event.confirmationCode
144
150
..clientMetadata.addAll (event.clientMetadata)
145
151
..analyticsMetadata = get <AnalyticsMetadataType >()? .toBuilder ();
146
152
147
- final clientSecret = _userPoolConfig.appClientSecret;
153
+ // ignore: invalid_use_of_internal_member
154
+ final clientSecret = _authOutputs.appClientSecret;
148
155
if (clientSecret != null ) {
149
156
b.secretHash = computeSecretHash (
150
157
event.username,
151
- _userPoolConfig.appClientId ,
158
+ _authOutputs.userPoolClientId ! ,
152
159
clientSecret,
153
160
);
154
161
}
0 commit comments