[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
1 changed files with 4 additions and 2 deletions

View File

@ -6,12 +6,14 @@ def init(options) 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