[#923] Support for multiple (external) registrations per user via Registration.
[akkoma] / lib / pleroma / web / auth / ldap_authenticator.ex
index 88217aab84dd533e632c2818bd823d706efcdcb7..51a0f0fa2f78122eeec9df85c55cf7347662ae9f 100644 (file)
@@ -12,10 +12,10 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
   @connection_timeout 10_000
   @search_timeout 10_000
 
-  def get_user(%Plug.Conn{} = conn) do
+  def get_user(%Plug.Conn{} = conn, params) do
     if Pleroma.Config.get([:ldap, :enabled]) do
       {name, password} =
-        case conn.params do
+        case params do
           %{"authorization" => %{"name" => name, "password" => password}} ->
             {name, password}
 
@@ -29,17 +29,19 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
 
         {:error, {:ldap_connection_error, _}} ->
           # When LDAP is unavailable, try default authenticator
-          Pleroma.Web.Auth.PleromaAuthenticator.get_user(conn)
+          Pleroma.Web.Auth.PleromaAuthenticator.get_user(conn, params)
 
         error ->
           error
       end
     else
       # Fall back to default authenticator
-      Pleroma.Web.Auth.PleromaAuthenticator.get_user(conn)
+      Pleroma.Web.Auth.PleromaAuthenticator.get_user(conn, params)
     end
   end
 
+  def get_by_external_registration(conn, params), do: get_user(conn, params)
+
   def handle_error(%Plug.Conn{} = _conn, error) do
     error
   end