From c8b8f1d32c28e2a0ccf30f999c417b7739b9c445 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 12 Oct 2018 06:25:50 +0200 Subject: [PATCH] [Pleroma.Plugs.UserIsAdminPlug]: Check if admin is true instead of false, fix error reporting --- lib/pleroma/plugs/user_is_admin_plug.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/plugs/user_is_admin_plug.ex b/lib/pleroma/plugs/user_is_admin_plug.ex index 2f812bf47..bdd057c44 100644 --- a/lib/pleroma/plugs/user_is_admin_plug.ex +++ b/lib/pleroma/plugs/user_is_admin_plug.ex @@ -6,12 +6,14 @@ defmodule Pleroma.Plugs.UserIsAdminPlug do options end - def call(%{assigns: %{user: %User{info: %{"is_admin" => false}}}} = conn, _) do + def call(%{assigns: %{user: %User{info: %{"is_admin" => true}}}} = conn, _) do conn - |> assign(:user, nil) end def call(conn, _) do conn + |> put_resp_content_type("application/json") + |> send_resp(403, Jason.encode!(%{error: "Not admin."})) + |> halt end end -- 2.45.2