Rename to allowlist
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user