View Source Appwrite.Consts.AuthenticationFactor (appwrite v0.1.9)
Provides constants and validation functions for different authentication factors.
This module defines the allowed authentication factors and provides helper functions to validate them. It ensures that only recognized authentication factors are used within the application.
Summary
Functions
Returns true
if the given factor
is a valid authentication factor, otherwise false
.
Guard clause to check if a given factor is a valid authentication factor.
Validates the given factor
and returns {:ok, factor}
if it is valid,
or {:error, "Invalid authentication factor"}
otherwise.
Validates the given factor
and returns it if it is valid. Raises an
ArgumentError
if the factor
is invalid.
Functions
Returns true
if the given factor
is a valid authentication factor, otherwise false
.
Examples
iex> AuthenticationFactor.is_valid_factor?("totp")
true
iex> AuthenticationFactor.is_valid_factor?("unknown")
false
Guard clause to check if a given factor is a valid authentication factor.
Examples
iex> AuthenticationFactor.valid_factor("email")
true
iex> AuthenticationFactor.valid_factor("unknown")
false
Validates the given factor
and returns {:ok, factor}
if it is valid,
or {:error, "Invalid authentication factor"}
otherwise.
Examples
iex> AuthenticationFactor.validate_factor("email")
{:ok, "email"}
iex> AuthenticationFactor.validate_factor("unknown")
{:error, "Invalid authentication factor"}
Validates the given factor
and returns it if it is valid. Raises an
ArgumentError
if the factor
is invalid.
Examples
iex> AuthenticationFactor.validate_factor!("phone")
"phone"
iex> AuthenticationFactor.validate_factor!("unknown")
** (ArgumentError) Invalid authentication factor: "unknown"