Merge remote-tracking branch 'remotes/origin/develop' into auth-improvements
[akkoma] / lib / pleroma / web / plugs / ensure_user_key_plug.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.Plugs.EnsureUserKeyPlug do
6 import Plug.Conn
7
8 @moduledoc "Ensures `conn.assigns.user` is initialized."
9
10 def init(opts) do
11 opts
12 end
13
14 def call(%{assigns: %{user: _}} = conn, _), do: conn
15
16 def call(conn, _) do
17 assign(conn, :user, nil)
18 end
19 end