2018-12-23 21:04:54 +01:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 23:44:49 +01:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2018-12-23 21:04:54 +01:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-12-15 20:06:44 +01:00
|
|
|
defmodule Pleroma.Captcha.Service do
|
|
|
|
@doc """
|
|
|
|
Request new captcha from a captcha service.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
2018-12-22 20:39:08 +01: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 20:06:44 +01:00
|
|
|
"""
|
2018-12-22 20:39:08 +01:00
|
|
|
@callback new() :: %{
|
|
|
|
type: atom(),
|
|
|
|
token: String.t(),
|
|
|
|
answer_data: any()
|
|
|
|
}
|
2018-12-15 20:06:44 +01:00
|
|
|
|
|
|
|
@doc """
|
|
|
|
Validated the provided captcha solution.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
* `token` the captcha is associated with
|
|
|
|
* `captcha` solution of the captcha to validate
|
2018-12-20 22:32:37 +01:00
|
|
|
* `answer_data` is the data needed to validate the answer (presumably encrypted)
|
2018-12-15 20:06:44 +01:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
`true` if captcha is valid, `false` if not
|
|
|
|
"""
|
2018-12-20 22:32:37 +01:00
|
|
|
@callback validate(
|
|
|
|
token :: String.t(),
|
|
|
|
captcha :: String.t(),
|
2018-12-22 20:39:08 +01:00
|
|
|
answer_data :: any()
|
2018-12-20 22:32:37 +01:00
|
|
|
) :: :ok | {:error, String.t()}
|
2018-12-15 20:06:44 +01:00
|
|
|
end
|