public virtual async Task SetTwoFactorEnabledAsync()

in src/Amazon.AspNetCore.Identity.Cognito/CognitoUserStore/CognitoUserStore.IUserTwoFactorStore.cs [72:102]


        public virtual async Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var request = new AdminSetUserSettingsRequest
            {
                Username = user.Username,
                UserPoolId = _pool.PoolID,
                MFAOptions = new List<MFAOptionType>()
                {
                    new MFAOptionType()
                    {
                        AttributeName = CognitoAttribute.PhoneNumber.AttributeName,
                        DeliveryMedium = enabled ? DeliveryMediumType.SMS : null // Undocumented SDK behavior: sending null disables SMS 2FA
                    }
                }
            };

            try
            {
                await _cognitoClient.AdminSetUserSettingsAsync(request, cancellationToken).ConfigureAwait(false);
            }
            catch (AmazonCognitoIdentityProviderException e)
            {
                throw new CognitoServiceException("Failed to set 2FA settings for the Cognito User", e);
            }
        }