I have a question regarding the confirmResetPassword method.
Shouldn't userNotFoundException be thrown when you call the confirmResetPassword method for an user who is not in Cognito User Pool?
Also shouldn't codeMismatchException be thrown when calling confirmResetPassword for a wrong confirmation code? per https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ForgotPassword.html#API_ForgotPassword_Errors
see also https://docs.amplify.aws/lib/auth/password_management/q/platform/ios/#reset-password.
However, no exception is thrown for both of these scenarios. In fact, the compiler notes that the Auth.confirmResetPassword does not throw any error therefore the "catch" phrase can never be reached
I also referred to a similar issue -> AWS Amplify/amplify-js forgotPassword() returns no error with invalid userName
However, "Prevent User Existence Errors turned to Enabled" under app client no longer has a "legacy" option.
do {
var res = Amplify.Auth.confirmResetPassword(for: "username", with: " ", confirmationCode: self.pin.concat)
print(" res.resultPublisher", res.resultPublisher)
print("self.pin.concat", self.pin.concat)
print("Password reset confirmed")
} catch let error as AuthError {
print("Reset password failed with error \(error)")
if let cognitoAuthError = error.underlyingError as? AWSCognitoAuthError {
switch cognitoAuthError {
case .aliasExists:
print("alias exists")
case .codeDelivery:
print("code delivery")
case .codeExpired:
print("code expired")
case .codeMismatch:
Text("wrong code")
case .failedAttemptsLimitExceeded:
print("failed attempts limit exceeded")
case .deviceNotTracked:
print("device not tracked")
case .errorLoadingUI:
print("error loading UI")
case .invalidAccountTypeException:
print("invalid account type exception")
case .invalidParameter:
print("invalid parameter")
case .invalidPassword:
print("invalid password")
case .lambda:
print("lambda")
case .limitExceeded:
print("limit exceeded")
case .mfaMethodNotFound:
print("mfaMethodNotFound")
case .network:
print("network")
case .passwordResetRequired:
print("passwordResetRequired")
case .requestLimitExceeded:
print("requestLimitExceeded")
case .resourceNotFound:
print("resourceNotFound")
case .softwareTokenMFANotEnabled:
print("softwareTokenMFANotEnabled")
case .userCancelled:
print("userCancelled")
case .userNotConfirmed:
print("userNotConfirmed")
case .userNotFound:
print("userNotFound")
case .usernameExists:
print("usernameExists")
}
}
} catch {
print("Unexpected error: \(error)")
}[![enter image description here][1]][1]