diff options
author | lain <lain@soykaf.club> | 2020-08-04 11:00:30 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-08-04 11:00:30 +0000 |
commit | 28584bb2241c600fc6150fdae49b1eea6bd420e0 (patch) | |
tree | 18f8334bdd3daffed7b033492539e3b867e8d15f /lib | |
parent | e3953923aca1706ab508bfda1ab892304b29c09a (diff) | |
parent | 2f4289d455fbd2d949ac1e10d5ea2b9c78f15e82 (diff) | |
download | pleroma-28584bb2241c600fc6150fdae49b1eea6bd420e0.tar.gz |
Merge branch 'email-blacklist' into 'develop'
Add email blacklist, fixes #1404
Closes #1404
See merge request pleroma/pleroma!2837
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/user.ex | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 0c1fab223..09e606b37 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: "Invalid email"] + 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) |