logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

user_is_staff_plug.ex (604B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Plugs.UserIsStaffPlug do
  5. import Pleroma.Web.TranslationHelpers
  6. import Plug.Conn
  7. alias Pleroma.User
  8. def init(options) do
  9. options
  10. end
  11. def call(%{assigns: %{user: %User{is_admin: true}}} = conn, _), do: conn
  12. def call(%{assigns: %{user: %User{is_moderator: true}}} = conn, _), do: conn
  13. def call(conn, _) do
  14. conn
  15. |> render_error(:forbidden, "User is not a staff member.")
  16. |> halt()
  17. end
  18. end