when not defined, not allowed
This commit is contained in:
parent
135448398d
commit
f333ea1ed0
@ -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
|
||||
|
||||
|
||||
11
test/fun_core/basic_signup_whitelist_test.exs
Normal file
11
test/fun_core/basic_signup_whitelist_test.exs
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user