1
0
mirror of https://git.pleroma.social/sjw/pleroma.git synced 2024-11-15 20:36:44 +01:00

[Pleroma.Plugs.UserIsAdminPlug]: Check if admin is true instead of false, fix error reporting

This commit is contained in:
Haelwenn (lanodan) Monnier 2018-10-12 06:25:50 +02:00
parent 011a2e36b1
commit c8b8f1d32c
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE

View 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