Formatting fixes
This commit is contained in:
parent
b5518da904
commit
23549d3952
4 changed files with 18 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue