6ddb6b5e58fe9db12445da3260ed4cf2d3b467e2
[akkoma] / lib / pleroma / web / plugs / set_user_session_id_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.SetUserSessionIdPlug do
6 import Plug.Conn
7 alias Pleroma.User
8
9 def init(opts) do
10 opts
11 end
12
13 def call(%{assigns: %{user: %User{id: id}}} = conn, _) do
14 put_session(conn, :user_id, id)
15 end
16
17 def call(conn, _), do: conn
18 end