2018-12-23 13:04:54 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2018-12-31 08:41:47 -07:00
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 13:04:54 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-12-15 12:06:44 -07:00
|
|
|
defmodule Pleroma.Captcha.Service do
|
|
|
|
@doc """
|
|
|
|
Request new captcha from a captcha service.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
2018-12-22 12:39:08 -07:00
|
|
|
Type/Name of the service, the token to identify the captcha,
|
|
|
|
the data of the answer and service-specific data to use the newly created captcha
|
2018-12-15 12:06:44 -07:00
|
|
|
"""
|
2018-12-22 12:39:08 -07:00
|
|
|
@callback new() :: %{
|
|
|
|
type: atom(),
|
|
|
|
token: String.t(),
|
|
|
|
answer_data: any()
|
|
|
|
}
|
2018-12-15 12:06:44 -07:00
|
|
|
|
|
|
|
@doc """
|
|
|
|
Validated the provided captcha solution.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
* `token` the captcha is associated with
|
|
|
|
* `captcha` solution of the captcha to validate
|
2018-12-20 14:32:37 -07:00
|
|
|
* `answer_data` is the data needed to validate the answer (presumably encrypted)
|
2018-12-15 12:06:44 -07:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
`true` if captcha is valid, `false` if not
|
|
|
|
"""
|
2018-12-20 14:32:37 -07:00
|
|
|
@callback validate(
|
|
|
|
token :: String.t(),
|
|
|
|
captcha :: String.t(),
|
2018-12-22 12:39:08 -07:00
|
|
|
answer_data :: any()
|
2018-12-20 14:32:37 -07:00
|
|
|
) :: :ok | {:error, String.t()}
|
2018-12-15 12:06:44 -07:00
|
|
|
end
|