Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F21907418
native.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
853 B
Referenced Files
None
Subscribers
None
native.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Captcha.Native
do
alias
Pleroma.Captcha.Service
@behaviour
Service
@impl
Service
def
new
do
case
Captcha
.
get
()
do
:error
->
%{
error
:
:captcha_error
}
{
:ok
,
answer_data
,
img_binary
}
->
%{
type
:
:native
,
token
:
token
(),
url
:
"data:image/png;base64,"
<>
Base
.
encode64
(
img_binary
),
answer_data
:
answer_data
}
end
end
@impl
Service
def
validate
(
_token
,
captcha
,
captcha
)
when
not
is_nil
(
captcha
),
do
:
:ok
def
validate
(
_token
,
_captcha
,
_answer
),
do
:
{
:error
,
:invalid
}
defp
token
do
10
|>
:crypto
.
strong_rand_bytes
()
|>
Base
.
url_encode64
(
padding
:
false
)
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sun, Dec 28, 1:41 AM (18 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
724371
Default Alt Text
native.ex (853 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment