defmodule BasicSignupAllowlist do import FunCore.BasicSignupAllowlist @moduledoc """ Checks if an email address is allowed based on the SIGNUP_ALLOWLIST_EMAILS env variable. """ @doc """ Checks if an email address is allowed based on the SIGNUP_ALLOWLIST_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 allowlist ## Examples iex> System.delete_env("SIGNUP_ALLOWLIST_EMAILS") iex> BasicSignupAllowlist.mail_allowlisted("joe@example.com") false iex> System.put_env("SIGNUP_ALLOWLIST_EMAILS","*") iex> BasicSignupAllowlist.mail_allowlisted("joe@example.com") true """ def mail_allowlisted(email) do env_value = System.get_env("SIGNUP_ALLOWLIST_EMAILS") mail_allowlisted_fun(env_value, email) end end