Remove privileged_staff
Everything that was done through this setting, can now be set by giving the proper privileges to the roles.
This commit is contained in:
parent
b1ff5241c2
commit
5a65e2dac5
8 changed files with 4 additions and 120 deletions
|
|
@ -47,7 +47,6 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
|||
federation: federation(),
|
||||
fields_limits: fields_limits(),
|
||||
post_formats: Config.get([:instance, :allowed_post_formats]),
|
||||
privileged_staff: Config.get([:instance, :privileged_staff]),
|
||||
birthday_required: Config.get([:instance, :birthday_required]),
|
||||
birthday_min_age: Config.get([:instance, :birthday_min_age])
|
||||
},
|
||||
|
|
|
|||
|
|
@ -69,8 +69,7 @@ defmodule Pleroma.Web.Nodeinfo.Nodeinfo do
|
|||
mailerEnabled: Config.get([Pleroma.Emails.Mailer, :enabled], false),
|
||||
features: features,
|
||||
restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
|
||||
skipThreadContainment: Config.get([:instance, :skip_thread_containment], false),
|
||||
privilegedStaff: Config.get([:instance, :privileged_staff])
|
||||
skipThreadContainment: Config.get([:instance, :skip_thread_containment], false)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.Plugs.EnsureStaffPrivilegedPlug do
|
||||
@moduledoc """
|
||||
Ensures staff are privileged enough to do certain tasks.
|
||||
"""
|
||||
import Pleroma.Web.TranslationHelpers
|
||||
import Plug.Conn
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.User
|
||||
|
||||
def init(options) do
|
||||
options
|
||||
end
|
||||
|
||||
def call(%{assigns: %{user: %User{is_admin: true}}} = conn, _), do: conn
|
||||
|
||||
def call(%{assigns: %{user: %User{is_moderator: true}}} = conn, _) do
|
||||
if Config.get!([:instance, :privileged_staff]) do
|
||||
conn
|
||||
else
|
||||
conn
|
||||
|> render_error(:forbidden, "User is not an admin.")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
def call(conn, _) do
|
||||
conn
|
||||
|> render_error(:forbidden, "User is not a staff member.")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
|
@ -101,10 +101,6 @@ defmodule Pleroma.Web.Router do
|
|||
plug(Pleroma.Web.Plugs.IdempotencyPlug)
|
||||
end
|
||||
|
||||
pipeline :require_privileged_staff do
|
||||
plug(Pleroma.Web.Plugs.EnsureStaffPrivilegedPlug)
|
||||
end
|
||||
|
||||
pipeline :require_admin do
|
||||
plug(Pleroma.Web.Plugs.UserIsAdminPlug)
|
||||
end
|
||||
|
|
@ -273,11 +269,6 @@ defmodule Pleroma.Web.Router do
|
|||
get("/chats/:id/messages", ChatController, :messages)
|
||||
end
|
||||
|
||||
# AdminAPI: admins and mods (staff) can perform these actions (if enabled by config)
|
||||
scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
|
||||
pipe_through([:admin_api, :require_privileged_staff])
|
||||
end
|
||||
|
||||
# AdminAPI: admins and mods (staff) can perform these actions
|
||||
scope "/api/v1/pleroma/admin", Pleroma.Web.AdminAPI do
|
||||
pipe_through(:admin_api)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue