Reserve a few user names
These are all names that are used for domain.com/:route routes or projected to be.
This commit is contained in:
parent
922abcda61
commit
91724d160a
@ -220,6 +220,35 @@
|
|||||||
credentials: true,
|
credentials: true,
|
||||||
headers: ["Authorization", "Content-Type", "Idempotency-Key"]
|
headers: ["Authorization", "Content-Type", "Idempotency-Key"]
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.User,
|
||||||
|
restricted_nicknames: [
|
||||||
|
"main",
|
||||||
|
"users",
|
||||||
|
"settings",
|
||||||
|
"objects",
|
||||||
|
"activities",
|
||||||
|
"web",
|
||||||
|
"registration",
|
||||||
|
"friend-requests",
|
||||||
|
"pleroma",
|
||||||
|
"api",
|
||||||
|
"tag",
|
||||||
|
"notice",
|
||||||
|
"status",
|
||||||
|
"user-search",
|
||||||
|
"ostatus_subscribe",
|
||||||
|
"oauth",
|
||||||
|
"push",
|
||||||
|
"relay",
|
||||||
|
"inbox",
|
||||||
|
".well-known",
|
||||||
|
"nodeinfo",
|
||||||
|
"auth",
|
||||||
|
"proxy",
|
||||||
|
"dev",
|
||||||
|
"internal"
|
||||||
|
]
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
# of this file so it overrides the configuration defined above.
|
# of this file so it overrides the configuration defined above.
|
||||||
import_config "#{Mix.env()}.exs"
|
import_config "#{Mix.env()}.exs"
|
||||||
|
@ -197,6 +197,7 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
|
|||||||
|> validate_confirmation(:password)
|
|> validate_confirmation(:password)
|
||||||
|> unique_constraint(:email)
|
|> unique_constraint(:email)
|
||||||
|> unique_constraint(:nickname)
|
|> unique_constraint(:nickname)
|
||||||
|
|> validate_exclusion(:nickname, Pleroma.Config.get([Pleroma.User, :restricted_nicknames]))
|
||||||
|> validate_format(:nickname, local_nickname_regex())
|
|> validate_format(:nickname, local_nickname_regex())
|
||||||
|> validate_format(:email, @email_regex)
|
|> validate_format(:email, @email_regex)
|
||||||
|> validate_length(:bio, max: 1000)
|
|> validate_length(:bio, max: 1000)
|
||||||
|
@ -153,6 +153,20 @@ test "it requires an email, name, nickname and password, bio is optional" do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it restricts certain nicknames" do
|
||||||
|
[restricted_name | _] = Pleroma.Config.get([Pleroma.User, :restricted_nicknames])
|
||||||
|
|
||||||
|
assert is_bitstring(restricted_name)
|
||||||
|
|
||||||
|
params =
|
||||||
|
@full_user_data
|
||||||
|
|> Map.put(:nickname, restricted_name)
|
||||||
|
|
||||||
|
changeset = User.register_changeset(%User{}, params)
|
||||||
|
|
||||||
|
refute changeset.valid?
|
||||||
|
end
|
||||||
|
|
||||||
test "it sets the password_hash, ap_id and following fields" do
|
test "it sets the password_hash, ap_id and following fields" do
|
||||||
changeset = User.register_changeset(%User{}, @full_user_data)
|
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user