View Source Mobilizon.Service.Auth.Authenticator behaviour (Mobilizon v5.0.0-beta.1)

Module to handle authentification (currently through database or LDAP)

Summary

Types

@type tokens() :: %{access_token: String.t(), refresh_token: String.t()}
@type tokens_with_user() :: %{
  access_token: String.t(),
  refresh_token: String.t(),
  user: Mobilizon.Users.User.t()
}
@type ttl() :: {pos_integer(), :second | :minute | :hour | :week}

Callbacks

@callback can_change_email?(Mobilizon.Users.User.t()) :: boolean()
@callback can_change_password?(Mobilizon.Users.User.t()) :: boolean()
@callback login(String.t(), String.t()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, any()}
@callback provider_name() :: String.t() | nil

Functions

Link to this function

authenticate(email, password)

View Source
@spec authenticate(String.t(), String.t()) :: {:ok, tokens_with_user()}
Link to this function

can_change_password?(user)

View Source
Link to this function

can_reset_password?(user)

View Source
@spec can_reset_password?(Mobilizon.Users.User.t()) :: boolean()
@spec fetch_user(String.t()) :: Mobilizon.Users.User.t() | {:error, :user_not_found}
Link to this function

generate_access_token(user, ttl \\ nil)

View Source
@spec generate_access_token(
  Mobilizon.Users.User.t() | ApplicationToken.t(),
  ttl() | nil
) ::
  {:ok, String.t()} | {:error, any()}

Generates access token for an user.

Link to this function

generate_refresh_token(user, ttl \\ nil)

View Source
@spec generate_refresh_token(
  Mobilizon.Users.User.t() | ApplicationToken.t(),
  ttl() | nil
) ::
  {:ok, String.t()} | {:error, any()}

Generates refresh token for an user.

@spec generate_tokens(Mobilizon.Users.User.t() | ApplicationToken.t()) ::
  {:ok, tokens()} | {:error, any()}

Generates access token and refresh token for an user.

@spec has_password?(Mobilizon.Users.User.t()) :: boolean()
@spec login(String.t(), String.t()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, any()}