Merge branch 'reserve-user-names' into 'develop'
Reserve a few user names See merge request pleroma/pleroma!594
This commit is contained in:
commit
cff0292d4b
5 changed files with 61 additions and 3 deletions
|
@ -137,8 +137,8 @@
|
|||
logo_mask: true,
|
||||
logo_margin: "0.1em",
|
||||
background: "/static/aurora_borealis.jpg",
|
||||
redirect_root_no_login: "/~/main/all",
|
||||
redirect_root_login: "/~/main/friends",
|
||||
redirect_root_no_login: "/main/all",
|
||||
redirect_root_login: "/main/friends",
|
||||
show_instance_panel: true,
|
||||
scope_options_enabled: false,
|
||||
formatting_options_enabled: false,
|
||||
|
@ -220,6 +220,37 @@
|
|||
credentials: true,
|
||||
headers: ["Authorization", "Content-Type", "Idempotency-Key"]
|
||||
|
||||
config :pleroma, Pleroma.User,
|
||||
restricted_nicknames: [
|
||||
"about",
|
||||
"~",
|
||||
"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
|
||||
# of this file so it overrides the configuration defined above.
|
||||
import_config "#{Mix.env()}.exs"
|
||||
|
|
|
@ -197,6 +197,7 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
|
|||
|> validate_confirmation(:password)
|
||||
|> unique_constraint(:email)
|
||||
|> unique_constraint(:nickname)
|
||||
|> validate_exclusion(:nickname, Pleroma.Config.get([Pleroma.User, :restricted_nicknames]))
|
||||
|> validate_format(:nickname, local_nickname_regex())
|
||||
|> validate_format(:email, @email_regex)
|
||||
|> validate_length(:bio, max: 1000)
|
||||
|
|
|
@ -138,7 +138,8 @@ def nodeinfo(conn, %{"version" => "2.0"}) do
|
|||
},
|
||||
accountActivationRequired: Keyword.get(instance, :account_activation_required, false),
|
||||
invitesEnabled: Keyword.get(instance, :invites_enabled, false),
|
||||
features: features
|
||||
features: features,
|
||||
restrictedNicknames: Pleroma.Config.get([Pleroma.User, :restricted_nicknames])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,6 +153,20 @@ test "it requires an email, name, nickname and password, bio is optional" do
|
|||
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
|
||||
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||
|
||||
|
|
|
@ -19,6 +19,17 @@ test "nodeinfo shows staff accounts", %{conn: conn} do
|
|||
assert user.ap_id in result["metadata"]["staffAccounts"]
|
||||
end
|
||||
|
||||
test "nodeinfo shows restricted nicknames", %{conn: conn} do
|
||||
conn =
|
||||
conn
|
||||
|> get("/nodeinfo/2.0.json")
|
||||
|
||||
assert result = json_response(conn, 200)
|
||||
|
||||
assert Pleroma.Config.get([Pleroma.User, :restricted_nicknames]) ==
|
||||
result["metadata"]["restrictedNicknames"]
|
||||
end
|
||||
|
||||
test "returns 404 when federation is disabled", %{conn: conn} do
|
||||
instance =
|
||||
Application.get_env(:pleroma, :instance)
|
||||
|
|
Loading…
Reference in a new issue