Skip to content

Commit e7d458f

Browse files
committed
updated to match Android
1 parent 08fb4e5 commit e7d458f

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

Sources/Authenticator/Resources/en.lproj/Localizable.strings

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
/* Confirm Sign In with Code */
8181
"authenticator.confirmSignInWithCode.button.submit" = "Submit";
8282
"authenticator.confirmSignInWithCode.button.backToSignIn" = "Back to Sign In";
83-
"authenticator.confirmSignInWithCode.field.email.code.label" = "Enter the verification code sent to your email to complete this sign-in.";
84-
"authenticator.confirmSignInWithCode.field.phone.code.label" = "Enter the verification code sent to your phone to complete this sign-in.";
8583

8684
/* Confirm Sign In with TOTP */
8785
"authenticator.confirmSignInWithCode.totp.title" = "Enter your one-time passcode";
@@ -91,7 +89,7 @@
9189
"authenticator.confirmSignInWithCode.totp.button.backToSignIn" = "Back to Sign In";
9290

9391
/* Continue Sign In with MFA Setup Selection */
94-
"authenticator.continueSignInWithMFASetupSelection.email.radioButton.title" = "Email";
92+
"authenticator.continueSignInWithMFASetupSelection.email.radioButton.title" = "Email Message";
9593
"authenticator.continueSignInWithMFASetupSelection.totp.radioButton.title" = "Authenticator App (TOTP)";
9694
"authenticator.continueSignInWithMFASetupSelection.button.continue" = "Continue";
9795
"authenticator.continueSignInWithMFASetupSelection.title" = "Choose your preferred two-factor authentication method to set up";
@@ -109,7 +107,7 @@
109107
"authenticator.continueSignInWithMFASelection.subtitle" = "For added security, choose how you want to verify your identity for this sign-in.";
110108
"authenticator.continueSignInWithMFASelection.sms.radioButton.title" = "Text Message (SMS)";
111109
"authenticator.continueSignInWithMFASelection.totp.radioButton.title" = "Authenticator App (TOTP)";
112-
"authenticator.continueSignInWithMFASelection.email.radioButton.title" = "Email";
110+
"authenticator.continueSignInWithMFASelection.email.radioButton.title" = "Email Message";
113111
"authenticator.continueSignInWithMFASelection.button.submit" = "Continue";
114112
"authenticator.continueSignInWithMFASelection.button.backToSignIn" = "Back to Sign In";
115113

@@ -176,8 +174,8 @@
176174
"authenticator.validator.field.phoneNumber.format" = "Invalid phone number";
177175

178176
/* Authenticator Banner Messages */
179-
"authenticator.banner.sendCode" = "A confirmation code has been sent to %@"; // Argument is the destination where a code was sent. E.g. "axxx@axxx.com"
180-
"authenticator.banner.sendCodeGeneric" = "A confirmation code has been sent";
177+
"authenticator.banner.sendCode" = "A verification code has been sent to %@"; // Argument is the destination where a code was sent. E.g. "axxx@axxx.com"
178+
"authenticator.banner.sendCodeGeneric" = "A verification code has been sent";
181179

182180
/* Authenticator Error View */
183181
"authenticator.authenticatorError.title" = "Something went wrong";
@@ -189,9 +187,9 @@
189187
"authenticator.authError.continueSignInWithMFASelection.noSelectionError" = "Please select an MFA method to continue";
190188
"authenticator.unknownError" = "Sorry, something went wrong";
191189

192-
"authenticator.cognitoError.codeDelivery" = "Could not send confirmation code";
193-
"authenticator.cognitoError.codeExpired" = "Confirmation code has expired";
194-
"authenticator.cognitoError.codeMismatch" = "Incorrect confirmation code";
190+
"authenticator.cognitoError.codeDelivery" = "Could not send verification code";
191+
"authenticator.cognitoError.codeExpired" = "Verification code has expired";
192+
"authenticator.cognitoError.codeMismatch" = "Incorrect verification code";
195193
"authenticator.cognitoError.invalidPassword" = "The provided password is not valid";
196194
"authenticator.cognitoError.network" = "Please check your connectivity";
197195
"authenticator.cognitoError.usernameExists" = "Username already exists";

Sources/Authenticator/States/ConfirmSignInWithCodeState.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ public class ConfirmSignInWithCodeState: AuthenticatorBaseState {
2323
credentials: Credentials())
2424
}
2525

26-
/// The `Amplify.AuthCodeDeliveryDetails` associated with this state. If the Authenticator is not in the `.confirmSignInWithMFACode` step, it returns `nil`
26+
/// The `Amplify.AuthCodeDeliveryDetails` associated with this state. If the Authenticator is not in the `.confirmSignInWithMFACode` or `confirmSignInWithOTP` step, it returns `nil`
2727
public var deliveryDetails: AuthCodeDeliveryDetails? {
28-
guard case .confirmSignInWithMFACode(let deliveryDetails) = authenticatorState.step else {
28+
switch authenticatorState.step {
29+
case .confirmSignInWithMFACode(let deliveryDetails),
30+
.confirmSignInWithOTP(let deliveryDetails):
31+
return deliveryDetails
32+
default:
2933
return nil
3034
}
31-
32-
return deliveryDetails
3335
}
3436

3537
/// Attempts to confirm the user's sign in using the provided confirmation code.

Sources/Authenticator/Views/Internal/ConfirmSignInWithCodeView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ struct ConfirmSignInWithCodeView<Header: View,
5555

5656
private var textFieldLabel: String {
5757
switch getCurrentMFAType {
58-
case .sms, .none:
59-
return "authenticator.confirmSignInWithCode.field.phone.code.label".localized()
60-
case .email:
61-
return "authenticator.confirmSignInWithCode.field.email.code.label".localized()
58+
case .sms, .none, .email:
59+
return "authenticator.field.code.label".localized()
6260
case .totp:
6361
return "authenticator.field.totp.code.label".localized()
6462
}

Tests/AuthenticatorHostApp/AuthenticatorHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/AuthenticatorHostApp/AuthenticatorHostApp/ContentView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ enum SignInNextStepForTesting: String, CaseIterable, Identifiable {
1717
case continueSignInWithMFASetupSelection = "Continue with MFA Setup Selection"
1818
case confirmSignInWithEmailMFACode = "Confirm with Email MFA Code"
1919
case confirmSignInWithPhoneMFACode = "Confirm with Phone MFA Code"
20+
case confirmSignInWithTOTP = "Confirm with TOTP"
21+
case customAuth = "Confirm sign in with Custom Auth"
2022

2123
var id: String { self.rawValue }
2224

@@ -34,6 +36,10 @@ enum SignInNextStepForTesting: String, CaseIterable, Identifiable {
3436
return .confirmSignInWithOTP(.init(destination: .email("h***@a***.com")))
3537
case .confirmSignInWithPhoneMFACode:
3638
return .confirmSignInWithOTP(.init(destination: .phone("+11***")))
39+
case .confirmSignInWithTOTP:
40+
return .confirmSignInWithTOTPCode
41+
case .customAuth:
42+
return .confirmSignInWithCustomChallenge(nil)
3743
}
3844
}
3945
}

Tests/AuthenticatorTests/States/ConfirmSignInWithCodeStateTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ class ConfirmSignInWithCodeStateTests: XCTestCase {
9999
XCTAssertEqual(deliveryDetails.destination, destination)
100100
}
101101

102+
func testDeliveryDetails_onConfirmSignInWithEmailMFACodeStep_shouldReturnDetails() throws {
103+
let destination = DeliveryDestination.email("test@test.com")
104+
authenticatorState.mockedStep = .confirmSignInWithOTP(deliveryDetails: .init(destination: destination))
105+
106+
let deliveryDetails = try XCTUnwrap(state.deliveryDetails)
107+
XCTAssertEqual(deliveryDetails.destination, destination)
108+
}
109+
102110
func testDeliveryDetails_onUnexpectedStep_shouldReturnNil() throws {
103111
let destination = DeliveryDestination.sms("123456789")
104112
authenticatorState.mockedStep = .confirmSignUp(deliveryDetails: .init(destination: destination))

0 commit comments

Comments
 (0)