basic_signup_allowlist/lib/basic_signup_whitelist.ex

30 lines
835 B
Elixir

defmodule BasicSignupWhitelist do
import FunCore.BasicSignupWhitelist
@moduledoc """
Checks if an email address is allowed based on the SIGNUP_ALLOWED_EMAILS env variable.
"""
@doc """
Checks if an email address is allowed based on the SIGNUP_ALLOWED_EMAILS env variable.
Rules:
- Returns true if ALLOWED_EMAILS == "*" (all emails allowed)
- Returns true if email matches any entry in the comma-separated list
- Returns false if:
* Environment variable doesn't exist
* Environment variable is empty string
* Email not found in whitelist
## Examples
iex> BasicSignupWhitelist.mail_whitelisted("joe@example.com")
false
"""
def mail_whitelisted(email) do
env_value = System.get_env("SIGNUP_ALLOWED_EMAILS")
mail_whitelisted_fun(env_value, email)
end
end