logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

session_authentication_plug.ex (521B)


  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.Web.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