X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fplugs%2Fauthentication_plug.ex;h=beb02eb88bc5150ca2102c9e2ae3044c726e40be;hb=1c90bfb4f6889c84a7aa22f71575c07bca42d304;hp=d47c3fdae75e63deee1b7fda2e9693ac54e0f4d0;hpb=b403ea4d2b69cef4434ad68babdfb402d8227847;p=akkoma diff --git a/lib/pleroma/plugs/authentication_plug.ex b/lib/pleroma/plugs/authentication_plug.ex index d47c3fdae..beb02eb88 100644 --- a/lib/pleroma/plugs/authentication_plug.ex +++ b/lib/pleroma/plugs/authentication_plug.ex @@ -1,11 +1,14 @@ defmodule Pleroma.Plugs.AuthenticationPlug do alias Comeonin.Pbkdf2 import Plug.Conn + alias Pleroma.User def init(options) do options end + def call(%{assigns: %{user: %User{}}} = conn, _), do: conn + def call(conn, opts) do with {:ok, username, password} <- decode_header(conn), {:ok, user} <- opts[:fetcher].(username), @@ -41,7 +44,7 @@ defmodule Pleroma.Plugs.AuthenticationPlug do defp decode_header(conn) do with ["Basic " <> header] <- get_req_header(conn, "authorization"), {:ok, userinfo} <- Base.decode64(header), - [username, password] <- String.split(userinfo, ":") + [username, password] <- String.split(userinfo, ":", parts: 2) do {:ok, username, password} end