From 222312900e6d847e0d4823fb62b6eb3675a0180f Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Dec 2020 12:18:43 +0100 Subject: User: Don't allow local users in remote changesets --- lib/pleroma/user.ex | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index bcd5256c8..9222b5b2a 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -472,7 +472,20 @@ defmodule Pleroma.User do |> validate_format(:nickname, @email_regex) |> validate_length(:bio, max: bio_limit) |> validate_length(:name, max: name_limit) + |> validate_inclusion(:local, [true]) |> validate_fields(true) + |> validate_non_local() + end + + defp validate_non_local(cng) do + local? = get_field(cng, :local) + + if local? do + cng + |> add_error(:local, "User is local, can't update with this changeset.") + else + cng + end end def update_changeset(struct, params \\ %{}) do -- cgit v1.2.3 From 04af0bbe44ab4ebd83ee2f3b797768d6e255e365 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Dec 2020 13:39:29 +0100 Subject: User: Remove left-over (wrong) fix. --- lib/pleroma/user.ex | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 9222b5b2a..4b3a9d690 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -472,7 +472,6 @@ defmodule Pleroma.User do |> validate_format(:nickname, @email_regex) |> validate_length(:bio, max: bio_limit) |> validate_length(:name, max: name_limit) - |> validate_inclusion(:local, [true]) |> validate_fields(true) |> validate_non_local() end -- cgit v1.2.3