aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2020-08-02 14:53:42 -0500
committerAlex Gleason <alex@alexgleason.me>2020-08-02 14:53:42 -0500
commitdc88b6f0919cf5686af7d5b935e8ee462491704b (patch)
tree04dfcf531841f02036f7daa173796eb1727eb83a /lib/pleroma
parent70951d042b5d7b12608a3f73a73c757fc4204449 (diff)
downloadpleroma-dc88b6f0919cf5686af7d5b935e8ee462491704b.tar.gz
Add email blacklist, fixes #1404
Diffstat (limited to 'lib/pleroma')
-rw-r--r--lib/pleroma/user.ex11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index dcf6ebee2..d0cc098fe 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -676,10 +676,19 @@ defmodule Pleroma.User do
|> validate_required([:name, :nickname, :password, :password_confirmation])
|> validate_confirmation(:password)
|> unique_constraint(:email)
+ |> validate_format(:email, @email_regex)
+ |> validate_change(:email, fn :email, email ->
+ valid? =
+ Config.get([User, :email_blacklist])
+ |> Enum.all?(fn blacklisted_domain ->
+ !String.ends_with?(email, ["@" <> blacklisted_domain, "." <> blacklisted_domain])
+ end)
+
+ if valid?, do: [], else: [email: "Email domain is blacklisted"]
+ end)
|> unique_constraint(:nickname)
|> validate_exclusion(:nickname, Config.get([User, :restricted_nicknames]))
|> validate_format(:nickname, local_nickname_regex())
- |> validate_format(:email, @email_regex)
|> validate_length(:bio, max: bio_limit)
|> validate_length(:name, min: 1, max: name_limit)
|> validate_length(:registration_reason, max: reason_limit)