when not defined, not allowed

This commit is contained in:
Willem van den Ende 2025-09-14 16:06:50 +01:00
parent 135448398d
commit f333ea1ed0
2 changed files with 21 additions and 2 deletions

View File

@ -1,10 +1,18 @@
defmodule BasicSignupWhitelist do
@moduledoc """
Documentation for `BasicSignupWhitelist`.
Checks if an email address is allowed based on the SIGNUP_ALLOWED_EMAILS env variable.
"""
@doc """
false
Checks if an email address is allowed based on the SIGNUP_ALLOWED_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 whitelist
## Examples

View File

@ -0,0 +1,11 @@
defmodule FunCore.BasicSignupWhitelistTest do
use ExUnit.Case
def mail_whitelisted_fun(_signups_allowed, _email_received) do
false
end
test "When not set, not whitelisted" do
refute(mail_whitelisted_fun(nil, "joe@example.com"))
end
end