logo

pleroma

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

user_is_admin_plug.ex (527B)


  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.UserIsAdminPlug 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
  12. conn
  13. end
  14. def call(conn, _) do
  15. conn
  16. |> render_error(:forbidden, "User is not an admin.")
  17. |> halt()
  18. end
  19. end