File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
packages/amplify_authenticator/lib/src/widgets Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 16
16
library authenticator.form;
17
17
18
18
import 'package:amplify_authenticator/amplify_authenticator.dart' ;
19
+ import 'package:amplify_authenticator/src/enums/enums.dart' ;
19
20
import 'package:amplify_authenticator/src/mixins/authenticator_username_field.dart' ;
20
21
import 'package:amplify_authenticator/src/state/inherited_authenticator_state.dart' ;
21
22
import 'package:amplify_authenticator/src/state/inherited_config.dart' ;
@@ -293,7 +294,7 @@ class _SignUpFormState extends AuthenticatorFormState<SignUpForm> {
293
294
return const [];
294
295
}
295
296
296
- return runtimeAttributes
297
+ final runtimeFields = runtimeAttributes
297
298
.map ((attr) {
298
299
if (attr == CognitoUserAttributeKey .address) {
299
300
return SignUpFormField .address (required : true );
@@ -337,6 +338,24 @@ class _SignUpFormState extends AuthenticatorFormState<SignUpForm> {
337
338
})
338
339
.whereType <SignUpFormField >()
339
340
.toList ();
341
+
342
+ final hasSmsMfa = authConfig? .mfaTypes? .contains (MfaType .sms) ?? false ;
343
+ if (hasSmsMfa) {
344
+ final mfaConfiguration =
345
+ authConfig? .mfaConfiguration ?? MfaConfiguration .off;
346
+ final hasSmsField = runtimeFields.any (
347
+ (f) => f.field == SignUpField .phoneNumber,
348
+ );
349
+ if (! hasSmsField && mfaConfiguration != MfaConfiguration .off) {
350
+ runtimeFields.add (
351
+ SignUpFormField .phoneNumber (
352
+ required : mfaConfiguration == MfaConfiguration .on ,
353
+ ),
354
+ );
355
+ }
356
+ }
357
+
358
+ return runtimeFields;
340
359
}
341
360
}
342
361
You can’t perform that action at this time.
0 commit comments