X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fplugs%2Fuser_is_admin_plug.ex;h=ee808f31f2f53988ff7bbfdeba61977171ad48e3;hb=791bcfd90f41da9d77ab5a5ad6eec22ae8050b8a;hp=2f812bf47611fb26978196f082b193a7be682628;hpb=7076d45cb6661731201a0224628b748a0f6782e8;p=akkoma diff --git a/lib/pleroma/plugs/user_is_admin_plug.ex b/lib/pleroma/plugs/user_is_admin_plug.ex index 2f812bf47..ee808f31f 100644 --- a/lib/pleroma/plugs/user_is_admin_plug.ex +++ b/lib/pleroma/plugs/user_is_admin_plug.ex @@ -1,4 +1,9 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Plugs.UserIsAdminPlug do + import Pleroma.Web.TranslationHelpers import Plug.Conn alias Pleroma.User @@ -6,12 +11,13 @@ defmodule Pleroma.Plugs.UserIsAdminPlug do options end - def call(%{assigns: %{user: %User{info: %{"is_admin" => false}}}} = conn, _) do + def call(%{assigns: %{user: %User{is_admin: true}}} = conn, _) do conn - |> assign(:user, nil) end def call(conn, _) do conn + |> render_error(:forbidden, "User is not admin.") + |> halt end end