Skip to content

Commit c98ce74

Browse files
committed
chore: fix name of challenge to match with SDK changes and updated state machine
1 parent d7f3d5d commit c98ce74

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ abstract class CognitoConstants {
5858
static const challengeParamSmsMfaCode = 'SMS_MFA_CODE';
5959

6060
/// The `EMAIL_MFA_CODE` parameter.
61-
static const challengeParamEmailMfaCode = 'EMAIL_MFA_CODE';
61+
static const challengeParamEmailMfaCode = 'EMAIL_OTP_CODE';
6262

6363
/// The `SOFTWARE_TOKEN_MFA_CODE` parameter.
6464
static const challengeParamSoftwareTokenMfaCode = 'SOFTWARE_TOKEN_MFA_CODE';

packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ final class SignInStateMachine
211211
(type) => switch (type) {
212212
'SOFTWARE_TOKEN_MFA' => MfaType.totp,
213213
'SMS_MFA' => MfaType.sms,
214-
'EMAIL_MFA' => MfaType.email,
214+
'EMAIL_OTP' => MfaType.email,
215215
_ => () {
216216
logger.error('Unrecognized MFA type: $type');
217217
return null;
@@ -326,6 +326,8 @@ final class SignInStateMachine
326326
createSmsMfaRequest(event),
327327
ChallengeNameType.softwareTokenMfa when hasUserResponse =>
328328
createSoftwareTokenMfaRequest(event),
329+
ChallengeNameType.emailOtp when hasUserResponse =>
330+
createEmailMfaRequest(event),
329331
ChallengeNameType.selectMfaType when hasUserResponse =>
330332
createSelectMfaRequest(event),
331333
ChallengeNameType.mfaSetup when hasUserResponse =>
@@ -686,7 +688,7 @@ final class SignInStateMachine
686688
CognitoConstants.challengeParamAnswer: switch (selection) {
687689
'sms' => 'SMS_MFA',
688690
'totp' => 'SOFTWARE_TOKEN_MFA',
689-
'email' => 'EMAIL_MFA',
691+
'email' => 'EMAIL_OTP',
690692
_ => throw ArgumentError('Must be either SMS, Email, or TOTP'),
691693
},
692694
})
@@ -954,6 +956,7 @@ final class SignInStateMachine
954956
accessToken: accessToken,
955957
sms: enableMfaType == MfaType.sms ? MfaPreference.enabled : null,
956958
totp: enableMfaType == MfaType.totp ? MfaPreference.enabled : null,
959+
email: enableMfaType == MfaType.email ? MfaPreference.enabled : null,
957960
);
958961
} on Exception catch (e, st) {
959962
logger.error(

packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ abstract class AuthenticatorInputLocalizations {
297297
/// **'Authenticator App (TOTP)'**
298298
String get selectTotp;
299299

300+
/// Label for the radio button to select email as the user's chosen MFA method.
301+
///
302+
/// In en, this message translates to:
303+
/// **'Email'**
304+
String get selectEmail;
305+
300306
/// The instructional text for submitting a TOTP pass code
301307
///
302308
/// In en, this message translates to:

packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ class AuthenticatorInputLocalizationsEn
153153
@override
154154
String get selectTotp => 'Authenticator App (TOTP)';
155155

156+
@override
157+
String get selectEmail => 'Email';
158+
156159
@override
157160
String get totpCodePrompt =>
158161
'Please enter the code from your registered Authenticator app';

packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum InputField {
3333
rememberDevice,
3434
selectSms,
3535
selectTotp,
36+
selectEmail,
3637
totpCodePrompt,
3738
usernameType,
3839
}
@@ -171,6 +172,11 @@ class InputResolverKey {
171172
field: InputField.selectSms,
172173
);
173174

175+
static const selectEmail = InputResolverKey._(
176+
InputResolverKeyType.title,
177+
field: InputField.email,
178+
);
179+
174180
static const totpCodePrompt = InputResolverKey._(
175181
InputResolverKeyType.title,
176182
field: InputField.totpCodePrompt,
@@ -456,6 +462,8 @@ class InputResolver extends Resolver<InputResolverKey> {
456462
return AuthenticatorLocalizations.inputsOf(context).selectSms;
457463
case InputField.selectTotp:
458464
return AuthenticatorLocalizations.inputsOf(context).selectTotp;
465+
case InputField.selectEmail:
466+
return AuthenticatorLocalizations.inputsOf(context).selectEmail;
459467
case InputField.totpCodePrompt:
460468
return AuthenticatorLocalizations.inputsOf(context).totpCodePrompt;
461469
case InputField.usernameType:

0 commit comments

Comments
 (0)