private async Task ValidateRecaptcha()

in src/Unosquare.PassCore.Web/Controllers/PasswordController.cs [140:154]


        private async Task<bool> ValidateRecaptcha(string? recaptchaResponse)
        {
            // skip validation if we don't enable recaptcha
            if ((_options.Recaptcha != null) && string.IsNullOrWhiteSpace(_options.Recaptcha.PrivateKey))
                return true;
            else if ((_options.Recaptcha != null) && (string.IsNullOrEmpty(recaptchaResponse) != true))
            {
                var requestUrl = new Uri(
                    $"https://www.google.com/recaptcha/api/siteverify?secret={_options.Recaptcha.PrivateKey}&response={recaptchaResponse}");
                var validationResponse = await JsonClient.Get<Dictionary<string, object>>(requestUrl)
                    .ConfigureAwait(false);
                return Convert.ToBoolean(validationResponse["success"], System.Globalization.CultureInfo.InvariantCulture);
            }
            return false;
        }