[Pleroma.Plugs.UserIsAdminPlug]: Check if admin is true instead of false, fix error...
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 12 Oct 2018 04:25:50 +0000 (06:25 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 17 Nov 2018 19:25:53 +0000 (20:25 +0100)
lib/pleroma/plugs/user_is_admin_plug.ex

index 2f812bf47611fb26978196f082b193a7be682628..bdd057c44b4c6ff2fa331c4a6569706ff9bd2db3 100644 (file)
@@ -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