Merge branch 'ldap-call' into 'develop'

LDAP: fix compile warning

See merge request pleroma/pleroma!4270
This commit is contained in:
feld 2024-09-18 16:20:45 +00:00
commit 6358294943
3 changed files with 6 additions and 1 deletions

View file

View file

@ -94,6 +94,10 @@ defmodule Pleroma.LDAP do
:ok :ok
end end
def bind_user(name, password) do
GenServer.call(__MODULE__, {:bind_user, name, password})
end
defp connect do defp connect do
ldap = Config.get(:ldap, []) ldap = Config.get(:ldap, [])
host = Keyword.get(ldap, :host, "localhost") host = Keyword.get(ldap, :host, "localhost")

View file

@ -3,6 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Auth.LDAPAuthenticator do defmodule Pleroma.Web.Auth.LDAPAuthenticator do
alias Pleroma.LDAP
alias Pleroma.User alias Pleroma.User
import Pleroma.Web.Auth.Helpers, only: [fetch_credentials: 1] import Pleroma.Web.Auth.Helpers, only: [fetch_credentials: 1]
@ -19,7 +20,7 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
def get_user(%Plug.Conn{} = conn) do def get_user(%Plug.Conn{} = conn) do
with {:ldap, true} <- {:ldap, Pleroma.Config.get([:ldap, :enabled])}, with {:ldap, true} <- {:ldap, Pleroma.Config.get([:ldap, :enabled])},
{:ok, {name, password}} <- fetch_credentials(conn), {:ok, {name, password}} <- fetch_credentials(conn),
%User{} = user <- GenServer.call(Pleroma.LDAP, {:bind_user, name, password}) do %User{} = user <- LDAP.bind_user(name, password) do
{:ok, user} {:ok, user}
else else
{:ldap, _} -> {:ldap, _} ->