lib/pleroma/plugs/user_is_admin_plug.ex: Create
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 2 Oct 2018 17:13:21 +0000 (19:13 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 17 Nov 2018 19:25:52 +0000 (20:25 +0100)
lib/pleroma/plugs/user_is_admin_plug.ex [new file with mode: 0644]

diff --git a/lib/pleroma/plugs/user_is_admin_plug.ex b/lib/pleroma/plugs/user_is_admin_plug.ex
new file mode 100644 (file)
index 0000000..2f812bf
--- /dev/null
@@ -0,0 +1,17 @@
+defmodule Pleroma.Plugs.UserIsAdminPlug do
+  import Plug.Conn
+  alias Pleroma.User
+
+  def init(options) do
+    options
+  end
+
+  def call(%{assigns: %{user: %User{info: %{"is_admin" => false}}}} = conn, _) do
+    conn
+    |> assign(:user, nil)
+  end
+
+  def call(conn, _) do
+    conn
+  end
+end