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,6 +65,7 @@ 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} ->
try do
cond do cond do
ssl -> ssl ->
:application.ensure_all_started(:ssl) :application.ensure_all_started(:ssl)
@ -88,6 +89,9 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
end end
bind_user(connection, ldap, name, password) bind_user(connection, ldap, name, password)
after
:eldap.close(connection)
end
{:error, error} -> {:error, error} ->
Logger.error("Could not open LDAP connection: #{inspect(error)}") Logger.error("Could not open LDAP connection: #{inspect(error)}")