Blacklist misleading usernames (fixes #10)
This commit is contained in:
parent
c5b02fe5be
commit
00394a3559
4 changed files with 14 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
||||||
* Add minimal captcha module
|
* Add minimal captcha module
|
||||||
* Add minimal support/contact form
|
* Add minimal support/contact form
|
||||||
* Add captcha to registrations
|
* Add captcha to registrations
|
||||||
|
* Blacklist misleading username for new accounts
|
||||||
|
|
||||||
# management 0.2.0, 2021-01-19
|
# management 0.2.0, 2021-01-19
|
||||||
|
|
||||||
|
|
|
@ -186,8 +186,18 @@ defmodule RecycledCloud.Accounts.User do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp validate_username(changeset) do
|
defp validate_username(changeset) do
|
||||||
|
check_blacklist = fn changeset ->
|
||||||
|
username = get_field(changeset, :username)
|
||||||
|
if TheBigUsernameBlacklist.valid?(username) do
|
||||||
|
changeset
|
||||||
|
else
|
||||||
|
add_error(changeset, :username, "This username is blacklisted, you cannot use it.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
changeset
|
changeset
|
||||||
|> validate_required([:username])
|
|> validate_required([:username])
|
||||||
|
|> check_blacklist.()
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
3
mix.exs
3
mix.exs
|
@ -60,7 +60,8 @@ defmodule RecycledCloud.MixProject do
|
||||||
# FIXME: See https://github.com/gen-smtp/gen_smtp/issues/234
|
# FIXME: See https://github.com/gen-smtp/gen_smtp/issues/234
|
||||||
{:ranch, "~> 1.7.1", override: true},
|
{:ranch, "~> 1.7.1", override: true},
|
||||||
{:xmlrpc, "~> 1.4"},
|
{:xmlrpc, "~> 1.4"},
|
||||||
{:httpoison, "~> 1.8"}
|
{:httpoison, "~> 1.8"},
|
||||||
|
{:the_big_username_blacklist, "~> 0.1"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
1
mix.lock
1
mix.lock
|
@ -41,6 +41,7 @@
|
||||||
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
|
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
|
||||||
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.0", "da9d49ee7e6bb1c259d36ce6539cd45ae14d81247a2b0c90edf55e2b50507f7b", [:mix], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5cfe67ad464b243835512aa44321cee91faed6ea868d7fb761d7016e02915c3d"},
|
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.0", "da9d49ee7e6bb1c259d36ce6539cd45ae14d81247a2b0c90edf55e2b50507f7b", [:mix], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5cfe67ad464b243835512aa44321cee91faed6ea868d7fb761d7016e02915c3d"},
|
||||||
"telemetry_poller": {:hex, :telemetry_poller, "0.5.1", "21071cc2e536810bac5628b935521ff3e28f0303e770951158c73eaaa01e962a", [:rebar3], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4cab72069210bc6e7a080cec9afffad1b33370149ed5d379b81c7c5f0c663fd4"},
|
"telemetry_poller": {:hex, :telemetry_poller, "0.5.1", "21071cc2e536810bac5628b935521ff3e28f0303e770951158c73eaaa01e962a", [:rebar3], [{:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4cab72069210bc6e7a080cec9afffad1b33370149ed5d379b81c7c5f0c663fd4"},
|
||||||
|
"the_big_username_blacklist": {:hex, :the_big_username_blacklist, "0.1.2", "a2622f06a26279c9cd5216ada872c2dceb63bc2ade5c8714df0de65a24aa985c", [:mix], [], "hexpm", "9f411601209758d4a5ef9e247a1e7b908c0cd05e78171f51f07e68b7afb038fe"},
|
||||||
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
|
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
|
||||||
"xmlrpc": {:hex, :xmlrpc, "1.4.1", "e69711f5a15b297c6c27dd833726a6a0cf06bab9130ac6039b8031510a3af497", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:erlsom, "~> 1.4", [hex: :erlsom, repo: "hexpm", optional: false]}], "hexpm", "4680ce0e452f80ce69f405429fa35ecfbd5a385fe882a7f2666702da3cd173a7"},
|
"xmlrpc": {:hex, :xmlrpc, "1.4.1", "e69711f5a15b297c6c27dd833726a6a0cf06bab9130ac6039b8031510a3af497", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:erlsom, "~> 1.4", [hex: :erlsom, repo: "hexpm", optional: false]}], "hexpm", "4680ce0e452f80ce69f405429fa35ecfbd5a385fe882a7f2666702da3cd173a7"},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue