Rename to allowlist

This commit is contained in:
Your Name
2025-09-16 09:09:51 +00:00
parent 30548eae80
commit 490102c0a8
6 changed files with 73 additions and 27 deletions
@@ -1,5 +1,5 @@
defmodule BasicSignupWhitelist do
import FunCore.BasicSignupWhitelist
defmodule BasicSignupAllowlist do
import FunCore.BasicSignupAllowlist
@moduledoc """
Checks if an email address is allowed based on the SIGNUP_ALLOWLIST_EMAILS env variable.
@@ -14,20 +14,20 @@ defmodule BasicSignupWhitelist do
- Returns false if:
* Environment variable doesn't exist
* Environment variable is empty string
* Email not found in whitelist
* Email not found in allowlist
## Examples
iex> System.delete_env("SIGNUP_ALLOWLIST_EMAILS")
iex> BasicSignupWhitelist.mail_whitelisted("joe@example.com")
iex> BasicSignupAllowlist.mail_allowlisted("joe@example.com")
false
iex> System.put_env("SIGNUP_ALLOWLIST_EMAILS","*")
iex> BasicSignupWhitelist.mail_whitelisted("joe@example.com")
iex> BasicSignupAllowlist.mail_allowlisted("joe@example.com")
true
"""
def mail_whitelisted(email) do
def mail_allowlisted(email) do
env_value = System.get_env("SIGNUP_ALLOWLIST_EMAILS")
mail_whitelisted_fun(env_value, email)
mail_allowlisted_fun(env_value, email)
end
end
+2 -2
View File
@@ -1,4 +1,4 @@
defmodule FunCore.BasicSignupWhitelist do
defmodule FunCore.BasicSignupAllowlist do
def normalize(email) do
email |> String.trim() |> String.downcase()
end
@@ -9,7 +9,7 @@ defmodule FunCore.BasicSignupWhitelist do
|> Enum.map(&normalize/1)
end
def mail_whitelisted_fun(signups_allowed, email_received) do
def mail_allowlisted_fun(signups_allowed, email_received) do
case signups_allowed do
nil -> false
"*" -> true