diff options
author | lain <lain@soykaf.club> | 2020-12-02 12:18:43 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-12-02 12:18:43 +0100 |
commit | 222312900e6d847e0d4823fb62b6eb3675a0180f (patch) | |
tree | 5cb093d93e732d0ab8355614260ae752e5f26d51 /lib | |
parent | 57d0379b89bd323dacf4959b03c55519de173ec0 (diff) | |
download | pleroma-222312900e6d847e0d4823fb62b6eb3675a0180f.tar.gz |
User: Don't allow local users in remote changesets
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/user.ex | 13 |
1 files changed, 13 insertions, 0 deletions
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 |