diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | lib/recaptcha.ex | 2 |
2 files changed, 3 insertions, 1 deletions
@@ -88,7 +88,7 @@ Recaptcha provides the `verify/2` method. Below is an example using a Phoenix co `{:ok, %Recaptcha.Response{challenge_ts: timestamp, hostname: host}}` -> The captcha is valid, see the [documentation](https://developers.google.com/recaptcha/docs/verify#api-response) for more details. -`{:error, errors}` -> `errors` contains atomised versions of the errors returned by the API, See the [error documentation](https://developers.google.com/recaptcha/docs/verify#error-code-reference) for more details. Errors caused by timeouts in HTTPoison or Poison encoding are also returned as atoms. +`{:error, errors}` -> `errors` contains atomised versions of the errors returned by the API, See the [error documentation](https://developers.google.com/recaptcha/docs/verify#error-code-reference) for more details. Errors caused by timeouts in HTTPoison or Poison encoding are also returned as atoms. If the recaptcha request succeeds but the challenge is failed, a ``:challenge_failed` error is returned. `verify` method also accepts a keyword list as the third parameter with the following options: diff --git a/lib/recaptcha.ex b/lib/recaptcha.ex index 9e6be0f..30a5bd8 100644 --- a/lib/recaptcha.ex +++ b/lib/recaptcha.ex @@ -41,6 +41,8 @@ defmodule Recaptcha do {:error, Enum.map(errors, fn(error) -> atomise_api_error(error) end)} {:ok, %{"success" => true, "challenge_ts" => timestamp, "hostname" => host}} -> {:ok, %Recaptcha.Response{challenge_ts: timestamp, hostname: host}} + {:ok, %{"success" => false, "challenge_ts" => timestamp, "hostname" => host}} -> + {:error, [:challenge_failed]} end end |