diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignUpOptions.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignUpOptions.swift index 5d6505bfb6..c661c54855 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignUpOptions.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignUpOptions.swift @@ -11,7 +11,11 @@ public struct AWSAuthConfirmSignUpOptions { public let metadata: [String: String]? - public init(metadata: [String: String]? = nil) { + public let forceAliasCreation: Bool? + + public init(metadata: [String: String]? = nil, + forceAliasCreation: Bool? = nil) { self.metadata = metadata + self.forceAliasCreation = forceAliasCreation } } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Utils/ConfirmSignUpInput+Amplify.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Utils/ConfirmSignUpInput+Amplify.swift index 5590fccce0..12f057a7fb 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Utils/ConfirmSignUpInput+Amplify.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Utils/ConfirmSignUpInput+Amplify.swift @@ -13,6 +13,7 @@ extension ConfirmSignUpInput { confirmationCode: String, clientMetadata: [String: String]?, asfDeviceId: String?, + forceAliasCreation: Bool?, environment: UserPoolEnvironment ) { @@ -37,6 +38,7 @@ extension ConfirmSignUpInput { clientId: configuration.clientId, clientMetadata: clientMetadata, confirmationCode: confirmationCode, + forceAliasCreation: forceAliasCreation, secretHash: secretHash, userContextData: userContextData, username: username) diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift index 962ae5c95a..03f9257f99 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignUpTask.swift @@ -33,11 +33,13 @@ class AWSAuthConfirmSignUpTask: AuthConfirmSignUpTask, DefaultLogger { for: request.username, credentialStoreClient: authEnvironment.credentialsClient) let metadata = (request.options.pluginOptions as? AWSAuthConfirmSignUpOptions)?.metadata + let forceAliasCreation = (request.options.pluginOptions as? AWSAuthConfirmSignUpOptions)?.forceAliasCreation let client = try userPoolEnvironment.cognitoUserPoolFactory() let input = ConfirmSignUpInput(username: request.username, confirmationCode: request.code, clientMetadata: metadata, asfDeviceId: asfDeviceId, + forceAliasCreation: forceAliasCreation, environment: userPoolEnvironment) _ = try await client.confirmSignUp(input: input) log.verbose("Received success") diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/ResolverTests/SignUpState/ConfirmSignUpInputTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/ResolverTests/SignUpState/ConfirmSignUpInputTests.swift index 52e54270d4..f926817dc6 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/ResolverTests/SignUpState/ConfirmSignUpInputTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/ResolverTests/SignUpState/ConfirmSignUpInputTests.swift @@ -31,6 +31,7 @@ class ConfirmSignUpInputTests: XCTestCase { confirmationCode: "123", clientMetadata: [:], asfDeviceId: "asdfDeviceId", + forceAliasCreation: nil, environment: environment) XCTAssertNotNil(confirmSignUpInput.secretHash) @@ -55,6 +56,7 @@ class ConfirmSignUpInputTests: XCTestCase { confirmationCode: "123", clientMetadata: [:], asfDeviceId: nil, + forceAliasCreation: nil, environment: environment) XCTAssertNil(confirmSignUpInput.secretHash) diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpAPITests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpAPITests.swift index fe5c8124c2..92812c342d 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpAPITests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignUp/AWSAuthConfirmSignUpAPITests.swift @@ -24,7 +24,9 @@ class AWSAuthConfirmSignUpAPITests: BasePluginTest { func testSuccessfulSignUp() async throws { self.mockIdentityProvider = MockIdentityProvider( - mockConfirmSignUpResponse: { _ in + mockConfirmSignUpResponse: { request in + XCTAssertNil(request.clientMetadata) + XCTAssertNil(request.forceAliasCreation) return .init() } ) @@ -47,11 +49,14 @@ class AWSAuthConfirmSignUpAPITests: BasePluginTest { mockConfirmSignUpResponse: { request in XCTAssertNotNil(request.clientMetadata) XCTAssertEqual(request.clientMetadata?["key"], "value") + XCTAssertEqual(request.forceAliasCreation, true) return .init() } ) - let pluginOptions = AWSAuthConfirmSignUpOptions(metadata: ["key": "value"]) + let pluginOptions = AWSAuthConfirmSignUpOptions( + metadata: ["key": "value"], + forceAliasCreation: true) let options = AuthConfirmSignUpRequest.Options(pluginOptions: pluginOptions) let result = try await self.plugin.confirmSignUp( for: "jeffb",