moving plugs into web dir
[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.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 conn
15 |> put_session(:user_id, id)
16 end
17
18 def call(conn, _), do: conn
19 end