logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

user_fetcher_plug.ex (534B)


  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.UserFetcherPlug do
  5. alias Pleroma.User
  6. import Plug.Conn
  7. def init(options) do
  8. options
  9. end
  10. def call(conn, _options) do
  11. with %{auth_credentials: %{username: username}} <- conn.assigns,
  12. %User{} = user <- User.get_by_nickname_or_email(username) do
  13. assign(conn, :auth_user, user)
  14. else
  15. _ -> conn
  16. end
  17. end
  18. end