@@ -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,13 @@ 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 authOutputs = get <AuthOutputs >();
41
+ if (authOutputs? .userPoolId == null ||
42
+ authOutputs? .userPoolClientId == null ) {
40
43
throw const InvalidAccountTypeException .noUserPool ();
41
44
}
42
- return userPoolConfig ;
45
+ return authOutputs ! ;
43
46
}
44
47
45
48
ASFContextDataProvider get _contextDataProvider => getOrCreate ();
@@ -78,7 +81,7 @@ final class SignUpStateMachine
78
81
SignUpRequest .build (
79
82
(b) {
80
83
b
81
- ..clientId = _userPoolConfig.appClientId
84
+ ..clientId = _authOutputs.userPoolClientId
82
85
..username = event.parameters.username
83
86
..password = event.parameters.password
84
87
..clientMetadata.addAll (event.clientMetadata)
@@ -100,11 +103,12 @@ final class SignUpStateMachine
100
103
)
101
104
..analyticsMetadata = get <AnalyticsMetadataType >()? .toBuilder ();
102
105
103
- final clientSecret = _userPoolConfig.appClientSecret;
106
+ // ignore: invalid_use_of_internal_member
107
+ final clientSecret = _authOutputs.appClientSecret;
104
108
if (clientSecret != null ) {
105
109
b.secretHash = computeSecretHash (
106
110
event.parameters.username,
107
- _userPoolConfig.appClientId ,
111
+ _authOutputs.userPoolClientId ! ,
108
112
clientSecret,
109
113
);
110
114
}
@@ -138,17 +142,18 @@ final class SignUpStateMachine
138
142
await _cognito.confirmSignUp (
139
143
ConfirmSignUpRequest .build ((b) {
140
144
b
141
- ..clientId = _userPoolConfig.appClientId
145
+ ..clientId = _authOutputs.userPoolClientId
142
146
..username = event.username
143
147
..confirmationCode = event.confirmationCode
144
148
..clientMetadata.addAll (event.clientMetadata)
145
149
..analyticsMetadata = get <AnalyticsMetadataType >()? .toBuilder ();
146
150
147
- final clientSecret = _userPoolConfig.appClientSecret;
151
+ // ignore: invalid_use_of_internal_member
152
+ final clientSecret = _authOutputs.appClientSecret;
148
153
if (clientSecret != null ) {
149
154
b.secretHash = computeSecretHash (
150
155
event.username,
151
- _userPoolConfig.appClientId ,
156
+ _authOutputs.userPoolClientId ! ,
152
157
clientSecret,
153
158
);
154
159
}
0 commit comments