setUserPoolMfaConfig method

Future<SetUserPoolMfaConfigResponse> setUserPoolMfaConfig({
  1. required String userPoolId,
  2. UserPoolMfaType? mfaConfiguration,
  3. SmsMfaConfigType? smsMfaConfiguration,
  4. SoftwareTokenMfaConfigType? softwareTokenMfaConfiguration,
})

Set the user pool multi-factor authentication (MFA) configuration.

May throw InvalidParameterException. May throw TooManyRequestsException. May throw ResourceNotFoundException. May throw InvalidSmsRoleAccessPolicyException. May throw InvalidSmsRoleTrustRelationshipException. May throw NotAuthorizedException. May throw InternalErrorException.

Parameter userPoolId : The user pool ID.

Parameter mfaConfiguration : The MFA configuration. Valid values include:

  • OFF MFA will not be used for any users.
  • ON MFA is required for all users to sign in.
  • OPTIONAL MFA will be required only for individual users who have an MFA factor enabled.

Parameter smsMfaConfiguration : The SMS text message MFA configuration.

Parameter softwareTokenMfaConfiguration : The software token MFA configuration.

Implementation

Future<SetUserPoolMfaConfigResponse> setUserPoolMfaConfig({
  required String userPoolId,
  UserPoolMfaType? mfaConfiguration,
  SmsMfaConfigType? smsMfaConfiguration,
  SoftwareTokenMfaConfigType? softwareTokenMfaConfiguration,
}) async {
  ArgumentError.checkNotNull(userPoolId, 'userPoolId');
  _s.validateStringLength(
    'userPoolId',
    userPoolId,
    1,
    55,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.SetUserPoolMfaConfig'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'UserPoolId': userPoolId,
      if (mfaConfiguration != null)
        'MfaConfiguration': mfaConfiguration.toValue(),
      if (smsMfaConfiguration != null)
        'SmsMfaConfiguration': smsMfaConfiguration,
      if (softwareTokenMfaConfiguration != null)
        'SoftwareTokenMfaConfiguration': softwareTokenMfaConfiguration,
    },
  );

  return SetUserPoolMfaConfigResponse.fromJson(jsonResponse.body);
}