Skip to content

Commit

Permalink
updated to match Android
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh62 committed Oct 30, 2024
1 parent 08fb4e5 commit e7d458f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
16 changes: 7 additions & 9 deletions Sources/Authenticator/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@
/* Confirm Sign In with Code */
"authenticator.confirmSignInWithCode.button.submit" = "Submit";
"authenticator.confirmSignInWithCode.button.backToSignIn" = "Back to Sign In";
"authenticator.confirmSignInWithCode.field.email.code.label" = "Enter the verification code sent to your email to complete this sign-in.";
"authenticator.confirmSignInWithCode.field.phone.code.label" = "Enter the verification code sent to your phone to complete this sign-in.";

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

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

Expand Down Expand Up @@ -176,8 +174,8 @@
"authenticator.validator.field.phoneNumber.format" = "Invalid phone number";

/* Authenticator Banner Messages */
"authenticator.banner.sendCode" = "A confirmation code has been sent to %@"; // Argument is the destination where a code was sent. E.g. "[email protected]"
"authenticator.banner.sendCodeGeneric" = "A confirmation code has been sent";
"authenticator.banner.sendCode" = "A verification code has been sent to %@"; // Argument is the destination where a code was sent. E.g. "[email protected]"
"authenticator.banner.sendCodeGeneric" = "A verification code has been sent";

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

"authenticator.cognitoError.codeDelivery" = "Could not send confirmation code";
"authenticator.cognitoError.codeExpired" = "Confirmation code has expired";
"authenticator.cognitoError.codeMismatch" = "Incorrect confirmation code";
"authenticator.cognitoError.codeDelivery" = "Could not send verification code";
"authenticator.cognitoError.codeExpired" = "Verification code has expired";
"authenticator.cognitoError.codeMismatch" = "Incorrect verification code";
"authenticator.cognitoError.invalidPassword" = "The provided password is not valid";
"authenticator.cognitoError.network" = "Please check your connectivity";
"authenticator.cognitoError.usernameExists" = "Username already exists";
Expand Down
10 changes: 6 additions & 4 deletions Sources/Authenticator/States/ConfirmSignInWithCodeState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ public class ConfirmSignInWithCodeState: AuthenticatorBaseState {
credentials: Credentials())
}

/// The `Amplify.AuthCodeDeliveryDetails` associated with this state. If the Authenticator is not in the `.confirmSignInWithMFACode` step, it returns `nil`
/// The `Amplify.AuthCodeDeliveryDetails` associated with this state. If the Authenticator is not in the `.confirmSignInWithMFACode` or `confirmSignInWithOTP` step, it returns `nil`
public var deliveryDetails: AuthCodeDeliveryDetails? {
guard case .confirmSignInWithMFACode(let deliveryDetails) = authenticatorState.step else {
switch authenticatorState.step {
case .confirmSignInWithMFACode(let deliveryDetails),
.confirmSignInWithOTP(let deliveryDetails):
return deliveryDetails
default:
return nil
}

return deliveryDetails
}

/// Attempts to confirm the user's sign in using the provided confirmation code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ struct ConfirmSignInWithCodeView<Header: View,

private var textFieldLabel: String {
switch getCurrentMFAType {
case .sms, .none:
return "authenticator.confirmSignInWithCode.field.phone.code.label".localized()
case .email:
return "authenticator.confirmSignInWithCode.field.email.code.label".localized()
case .sms, .none, .email:
return "authenticator.field.code.label".localized()
case .totp:
return "authenticator.field.totp.code.label".localized()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"location" : "https://github.com/aws-amplify/amplify-swift",
"state" : {
"branch" : "feat/email-mfa-support-public",
"revision" : "f332d126512fd9e28cbe07f4b3fdb36ab9cff4cb"
"revision" : "a1432446796b621e1a624ffe58d39150ea705b31"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ enum SignInNextStepForTesting: String, CaseIterable, Identifiable {
case continueSignInWithMFASetupSelection = "Continue with MFA Setup Selection"
case confirmSignInWithEmailMFACode = "Confirm with Email MFA Code"
case confirmSignInWithPhoneMFACode = "Confirm with Phone MFA Code"
case confirmSignInWithTOTP = "Confirm with TOTP"
case customAuth = "Confirm sign in with Custom Auth"

var id: String { self.rawValue }

Expand All @@ -34,6 +36,10 @@ enum SignInNextStepForTesting: String, CaseIterable, Identifiable {
return .confirmSignInWithOTP(.init(destination: .email("h***@a***.com")))
case .confirmSignInWithPhoneMFACode:
return .confirmSignInWithOTP(.init(destination: .phone("+11***")))
case .confirmSignInWithTOTP:
return .confirmSignInWithTOTPCode
case .customAuth:
return .confirmSignInWithCustomChallenge(nil)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ class ConfirmSignInWithCodeStateTests: XCTestCase {
XCTAssertEqual(deliveryDetails.destination, destination)
}

func testDeliveryDetails_onConfirmSignInWithEmailMFACodeStep_shouldReturnDetails() throws {
let destination = DeliveryDestination.email("[email protected]")
authenticatorState.mockedStep = .confirmSignInWithOTP(deliveryDetails: .init(destination: destination))

let deliveryDetails = try XCTUnwrap(state.deliveryDetails)
XCTAssertEqual(deliveryDetails.destination, destination)
}

func testDeliveryDetails_onUnexpectedStep_shouldReturnNil() throws {
let destination = DeliveryDestination.sms("123456789")
authenticatorState.mockedStep = .confirmSignUp(deliveryDetails: .init(destination: destination))
Expand Down

0 comments on commit e7d458f

Please sign in to comment.