AdditionalInfos not accessible when execute a SignIn with nextStep = .newPasswordRequired
Describe the bug We have users in user pool with and without phone number, pre-registered (user can't signup). And we have added phone number as required attribute. In case without, we want to ask user to add new phone number with which he can validate his MFA connection. When we made first signIn, we receive nextStep = .newPasswordRequired but impossible to recover AdditionalInfos. Always = nil. After further investigations, we find that in AWSMobileClient+UserPoolAuthHelperCallbacks.swift in getNewPasswordDetails function, for SignInResult init the param "parameters" is never set. So SignInResult init made it always has empty array because he is optional and never set to recover AdditionalInfos (requiredAttributes).
To Reproduce Steps to reproduce the behavior:
- Create a user without a phone number in a cognito user pool with MFA enforced and where the phone number is a mandatory attribute
- Add a new user in user pool without phone number
- For first signIn, need to have nextStep = .newPasswordRequired
- See that AddiotionalInfos for newPasswordRequired are every time nil
Expected Behavior
We need to receive requiredAttributes in AdditionalInfos. Like described in the documentation : https://docs.amplify.aws/lib/auth/signin_next_steps/q/platform/ios/#confirm-signin-with-new-password
Code Snippet
AWSMobileClient+UserPoolAuthHelperCallbacks.swift :
func getNewPasswordDetails(_ newPasswordRequiredInput: AWSCognitoIdentityNewPasswordRequiredInput,
newPasswordRequiredCompletionSource: AWSTaskCompletionSource<AWSCognitoIdentityNewPasswordRequiredDetails>) {
self.userpoolOpsHelper.newPasswordRequiredTaskCompletionSource = newPasswordRequiredCompletionSource
let result = SignInResult(signInState: .newPasswordRequired, codeDetails: nil)
invokeSignInCallback(signResult: result, error: nil)
}
SignInResult.swift :
public struct SignInResult {
public let signInState: SignInState
public let parameters: [String: String]
public let codeDetails: UserCodeDeliveryDetails?
internal init(signInState: SignInState, parameters: [String: String] = [:], codeDetails: UserCodeDeliveryDetails? = nil) {
self.signInState = signInState
self.parameters = parameters
self.codeDetails = codeDetails
}
}
Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)?
Environment(please complete the following information):
- SDK Version: Amplify 1.26.2, AmplifyPlugins/AWSCognitoAuthPlugin 1.26.2
- Dependency Manager: Cocoapods
- Swift Version : 5.5.2
- Xcode Version: 13.2.1
Device Information (please complete the following information):
- Device: iPhone 12
- iOS Version: 15.3.1
- Specific to simulators:
Thank you for raising the PR to fix the issue, we will review this and get back to you if we need more info.