X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fplugs%2Fuser_fetcher_plug.ex;h=4089aa958865d2b0dea038fb0f175dadeb64c064;hb=19e559fe5130f66a967732a40ccea1ac39e85eb8;hp=7ed4602bbd2a5c43e4a96aba0b975657f05a4958;hpb=04b1c135543965860029557fc216eb38fd63b6c7;p=akkoma diff --git a/lib/pleroma/plugs/user_fetcher_plug.ex b/lib/pleroma/plugs/user_fetcher_plug.ex index 7ed4602bb..4089aa958 100644 --- a/lib/pleroma/plugs/user_fetcher_plug.ex +++ b/lib/pleroma/plugs/user_fetcher_plug.ex @@ -4,8 +4,6 @@ defmodule Pleroma.Plugs.UserFetcherPlug do alias Pleroma.User - alias Pleroma.Repo - import Plug.Conn def init(options) do @@ -14,26 +12,10 @@ defmodule Pleroma.Plugs.UserFetcherPlug do def call(conn, _options) do with %{auth_credentials: %{username: username}} <- conn.assigns, - {:ok, %User{} = user} <- user_fetcher(username) do - conn - |> assign(:auth_user, user) + %User{} = user <- User.get_by_nickname_or_email(username) do + assign(conn, :auth_user, user) else _ -> conn end end - - defp user_fetcher(username_or_email) do - { - :ok, - cond do - # First, try logging in as if it was a name - user = Repo.get_by(User, %{nickname: username_or_email}) -> - user - - # If we get nil, we try using it as an email - user = Repo.get_by(User, %{email: username_or_email}) -> - user - end - } - end end