diff --git a/Sources/Authenticator/Constants/ComponentInformation.swift b/Sources/Authenticator/Constants/ComponentInformation.swift index 49286e0..35dae44 100644 --- a/Sources/Authenticator/Constants/ComponentInformation.swift +++ b/Sources/Authenticator/Constants/ComponentInformation.swift @@ -8,6 +8,6 @@ import Foundation public class ComponentInformation { - public static let version = "1.0.0-dev-preview" + public static let version = "1.0.1" public static let name = "amplify-ui-swift-authenticator" } diff --git a/Sources/Authenticator/States/SignUpState.swift b/Sources/Authenticator/States/SignUpState.swift index a557ba9..3e8b59d 100644 --- a/Sources/Authenticator/States/SignUpState.swift +++ b/Sources/Authenticator/States/SignUpState.swift @@ -89,7 +89,18 @@ public class SignUpState: AuthenticatorBaseState { setBusy(true) let cognitoConfiguration = authenticatorState.configuration - var inputs = signUpFields.map { Field(field: $0) } + + var existingFields: Set = [] + var inputs = signUpFields.compactMap { field -> Field? in + guard !existingFields.contains(field.rawValue) else { + log.warn("Skipping configuring field of type '\(field.rawValue)' because it was already present.") + return nil + } + + existingFields.insert(field.rawValue) + return Field(field: field) + } + for attribute in cognitoConfiguration.verificationMechanisms { if let index = inputs.firstIndex(where: { $0.field.attributeType == attribute.asSignUpAttribute }) { if !inputs[index].field.isRequired { @@ -160,3 +171,18 @@ public extension SignUpState { } } } + +private extension SignUpField { + var rawValue: String { + switch attributeType { + case .username: + return "username" + case .password: + return "password" + case .passwordConfirmation: + return "passwordConfirmation" + default: + return attributeType.attributeKey?.rawValue ?? "unknown" + } + } +} diff --git a/Sources/Authenticator/Views/Primitives/PhoneNumberField.swift b/Sources/Authenticator/Views/Primitives/PhoneNumberField.swift index bfb7ddc..b475648 100644 --- a/Sources/Authenticator/Views/Primitives/PhoneNumberField.swift +++ b/Sources/Authenticator/Views/Primitives/PhoneNumberField.swift @@ -59,8 +59,10 @@ struct PhoneNumberField: View { CallingCodeField(callingCode: $callingCode) .foregroundColor(foregroundColor) .focused($focusedField, equals: .callingCode) - .onChange(of: callingCode) { text in - self.text = "\(text)\(phoneNumber)" + .onChange(of: callingCode) { code in + if !phoneNumber.isEmpty { + text = "\(code)\(phoneNumber)" + } } Divider()