[#1560] Misc. improvements in ActivityPubController federation state restrictions.
[akkoma] / lib / pleroma / plugs / ensure_authenticated_plug.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Plugs.EnsureAuthenticatedPlug do
6 import Plug.Conn
7 import Pleroma.Web.TranslationHelpers
8 alias Pleroma.User
9
10 def init(options) do
11 options
12 end
13
14 def call(%{assigns: %{user: %User{}}} = conn, _) do
15 conn
16 end
17
18 def call(conn, _) do
19 conn
20 |> render_error(:forbidden, "Invalid credentials.")
21 |> halt
22 end
23 end