aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/captcha
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/captcha')
-rw-r--r--lib/pleroma/captcha/captcha_service.ex3
-rw-r--r--lib/pleroma/captcha/kocaptcha.ex4
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/pleroma/captcha/captcha_service.ex b/lib/pleroma/captcha/captcha_service.ex
index ae1d6e7c7..907a73ad0 100644
--- a/lib/pleroma/captcha/captcha_service.ex
+++ b/lib/pleroma/captcha/captcha_service.ex
@@ -1,5 +1,4 @@
defmodule Pleroma.Captcha.Service do
-
@doc """
Request new captcha from a captcha service.
@@ -20,5 +19,5 @@ defmodule Pleroma.Captcha.Service do
`true` if captcha is valid, `false` if not
"""
- @callback validate(token :: String.t, captcha :: String.t) :: boolean
+ @callback validate(token :: String.t(), captcha :: String.t()) :: boolean
end
diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex
index abccbf6d3..173ce17f7 100644
--- a/lib/pleroma/captcha/kocaptcha.ex
+++ b/lib/pleroma/captcha/kocaptcha.ex
@@ -7,9 +7,11 @@ defmodule Pleroma.Captcha.Kocaptcha do
@impl Service
def new() do
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
+
case HTTPoison.get(endpoint <> "/new") do
{:error, _} ->
%{error: "Kocaptcha service unavailable"}
+
{:ok, res} ->
json_resp = Poison.decode!(res.body)
@@ -25,7 +27,7 @@ defmodule Pleroma.Captcha.Kocaptcha do
def validate(token, captcha) do
with false <- is_nil(captcha),
[{^token, saved_md5}] <- :ets.lookup(@ets, token),
- true <- (:crypto.hash(:md5, captcha) |> Base.encode16) == String.upcase(saved_md5) do
+ true <- :crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(saved_md5) do
# Clear the saved value
:ets.delete(@ets, token)