Retain the try do so an LDAP failure can fall back to local database.

This fixes tests but the automatic fallback may not be well documented behavior.
This commit is contained in:
Mark Felder 2024-09-15 23:18:17 -04:00
parent af3bf8a462
commit 91d1d7260b

View file

@ -65,30 +65,34 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
case :eldap.open([to_charlist(host)], options) do case :eldap.open([to_charlist(host)], options) do
{:ok, connection} -> {:ok, connection} ->
cond do try do
ssl -> cond do
:application.ensure_all_started(:ssl) ssl ->
:application.ensure_all_started(:ssl)
tls -> tls ->
case :eldap.start_tls( case :eldap.start_tls(
connection, connection,
tlsopts, tlsopts,
@connection_timeout @connection_timeout
) do ) do
:ok -> :ok ->
:ok :ok
error -> error ->
Logger.error("Could not start TLS: #{inspect(error)}") Logger.error("Could not start TLS: #{inspect(error)}")
:eldap.close(connection) :eldap.close(connection)
end end
true -> true ->
:ok :ok
end
bind_user(connection, ldap, name, password)
after
:eldap.close(connection)
end end
bind_user(connection, ldap, name, password)
{:error, error} -> {:error, error} ->
Logger.error("Could not open LDAP connection: #{inspect(error)}") Logger.error("Could not open LDAP connection: #{inspect(error)}")
{:error, {:ldap_connection_error, error}} {:error, {:ldap_connection_error, error}}