/// <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);
            }
        }
    }
예제 #2
0
 public IActionResult Index(HCaptchaVerifyResponse hCaptcha) => View(new IndexViewModel(hCaptcha));
예제 #3
0
 public IndexViewModel(HCaptchaVerifyResponse response = null)
 {
     Response = response;
 }