diff options
author | Ekaterina Vaartis <vaartis@cock.li> | 2018-12-15 22:08:26 +0300 |
---|---|---|
committer | Ekaterina Vaartis <vaartis@cock.li> | 2018-12-15 22:08:26 +0300 |
commit | 23549d39521386f217a57ef1aeb3d660eff06860 (patch) | |
tree | 984fe760a9449065e7fdf2511b7f4e3ee11fe1a7 /lib/pleroma/captcha | |
parent | b5518da90468ab1cde40593695d75f3d72d66783 (diff) | |
download | pleroma-23549d39521386f217a57ef1aeb3d660eff06860.tar.gz |
Formatting fixes
Diffstat (limited to 'lib/pleroma/captcha')
-rw-r--r-- | lib/pleroma/captcha/captcha_service.ex | 3 | ||||
-rw-r--r-- | lib/pleroma/captcha/kocaptcha.ex | 4 |
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) |