projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'feat/chat-list-pagination' into 'develop'
[akkoma]
/
lib
/
pleroma
/
captcha
/
kocaptcha.ex
diff --git
a/lib/pleroma/captcha/kocaptcha.ex
b/lib/pleroma/captcha/kocaptcha.ex
index 61688e778835ad1d2c5c55c98034c8d45a405538..eac6dfa365a4c0d8b536ea4f3c08f508611b0ab4 100644
(file)
--- a/
lib/pleroma/captcha/kocaptcha.ex
+++ b/
lib/pleroma/captcha/kocaptcha.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
21
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Captcha.Kocaptcha do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Captcha.Kocaptcha do
@@
-10,18
+10,19
@@
defmodule Pleroma.Captcha.Kocaptcha do
def new do
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
def new do
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
- case
Tesla
.get(endpoint <> "/new") do
+ case
Pleroma.HTTP
.get(endpoint <> "/new") do
{:error, _} ->
{:error, _} ->
- %{error:
"Kocaptcha service unavailable"
}
+ %{error:
:kocaptcha_service_unavailable
}
{:ok, res} ->
{:ok, res} ->
- json_resp =
Poi
son.decode!(res.body)
+ json_resp =
Ja
son.decode!(res.body)
%{
type: :kocaptcha,
token: json_resp["token"],
url: endpoint <> json_resp["url"],
%{
type: :kocaptcha,
token: json_resp["token"],
url: endpoint <> json_resp["url"],
- answer_data: json_resp["md5"]
+ answer_data: json_resp["md5"],
+ seconds_valid: Pleroma.Config.get([Pleroma.Captcha, :seconds_valid])
}
end
end
}
end
end
@@
-32,6
+33,6
@@
defmodule Pleroma.Captcha.Kocaptcha do
if not is_nil(captcha) and
:crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_data),
do: :ok,
if not is_nil(captcha) and
:crypto.hash(:md5, captcha) |> Base.encode16() == String.upcase(answer_data),
do: :ok,
- else: {:error,
"Invalid CAPTCHA"
}
+ else: {:error,
:invalid
}
end
end
end
end