basic_signup_allowlist/lib/basic_signup_allowlist.ex
Your Name 8112173ef4 refactor: rename mail_allowlisted to signup_allowed?
Follow Elixir naming conventions by using question mark suffix for boolean
functions. Renamed mail_allowlisted to signup_allowed? and mail_allowlisted_fun
to signup_allowed_fun throughout the codebase.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-16 09:44:11 +00:00

41 lines
1.2 KiB
Elixir

defmodule BasicSignupAllowlist do
import FunCore.BasicSignupAllowlist
@signup_allowlist_emails "SIGNUP_ALLOWLIST_EMAILS"
@moduledoc """
Checks if an email address is allowed based on the SIGNUP_ALLOWLIST_EMAILS env variable.
"""
@doc """
Returns the name of the environment variable used for the signup allowlist.
"""
def signup_allowlist_emails, do: @signup_allowlist_emails
@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.signup_allowed?("joe@example.com")
false
iex> System.put_env("SIGNUP_ALLOWLIST_EMAILS","*")
iex> BasicSignupAllowlist.signup_allowed?("joe@example.com")
true
"""
def signup_allowed?(email) do
env_value = System.get_env(@signup_allowlist_emails)
signup_allowed_fun(env_value, email)
end
end