diff --git a/lib/basic_signup_allowlist.ex b/lib/basic_signup_allowlist.ex index e531593..a5ec744 100644 --- a/lib/basic_signup_allowlist.ex +++ b/lib/basic_signup_allowlist.ex @@ -13,6 +13,7 @@ defmodule BasicSignupAllowlist do @spec signup_allowlist_emails() :: String.t() def signup_allowlist_emails, do: @signup_allowlist_emails + @doc """ Checks if an email address is allowed based on the SIGNUP_ALLOWLIST_EMAILS env variable. @@ -26,10 +27,10 @@ defmodule BasicSignupAllowlist do ## Examples - iex> System.delete_env("SIGNUP_ALLOWLIST_EMAILS") + iex> BasicSignupAllowlist.forbid_signup_with_any_email() iex> BasicSignupAllowlist.signup_allowed?("joe@example.com") false - iex> System.put_env("SIGNUP_ALLOWLIST_EMAILS", "*") + iex> BasicSignupAllowlist.allow_signup_with_all_emails() iex> BasicSignupAllowlist.signup_allowed?("joe@example.com") true @@ -39,4 +40,12 @@ defmodule BasicSignupAllowlist do env_value = System.get_env(@signup_allowlist_emails) signup_allowed_fun(env_value, email) end + + def allow_signup_with_all_emails() do + System.put_env(signup_allowlist_emails(), "*") + end + + def forbid_signup_with_any_email() do + System.delete_env(signup_allowlist_emails()) + end end