1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug do
15 public? = Config.get!([:instance, :public])
17 case {public?, conn} do
21 {false, %{assigns: %{user: %User{}}}} ->
26 |> put_resp_content_type("application/json")
27 |> send_resp(403, Jason.encode!(%{error: "This resource requires authentication."}))