Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
517B

  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. defmodule Pleroma.Plugs.SessionAuthenticationPlug do
  5. import Plug.Conn
  6. def init(options) do
  7. options
  8. end
  9. def call(conn, _) do
  10. with saved_user_id <- get_session(conn, :user_id),
  11. %{auth_user: %{id: ^saved_user_id}} <- conn.assigns do
  12. conn
  13. |> assign(:user, conn.assigns.auth_user)
  14. else
  15. _ -> conn
  16. end
  17. end
  18. end