/// <summary>
    /// Maps the string-based error codes to enums. Uses <see cref="ErrorCodeDictionary"/> as mapping table.
    /// </summary>
    /// <remarks>https://docs.hcaptcha.com/#server</remarks>
    public static IEnumerable <HCaptchaVerifyErrorCode> GetErrorCodes(this HCaptchaVerifyResponse response)
    {
        if (response?.ErrorCodes is null)
        {
            yield break;
        }

        foreach (string e in response.ErrorCodes)
        {
            if (ErrorCodeDictionary.TryGetValue(e, out HCaptchaVerifyErrorCode errorCode))
            {
                yield return(errorCode);
            }
            else
            {
                yield return(HCaptchaVerifyErrorCode.Unknown);
            }
        }
    }
Beispiel #2
0
 public IActionResult Index(HCaptchaVerifyResponse hCaptcha) => View(new IndexViewModel(hCaptcha));
 public IndexViewModel(HCaptchaVerifyResponse response = null)
 {
     Response = response;
 }