Remove LDAP mail attribute as a requirement for registering an account
This commit is contained in:
parent
b1b6a7dfa8
commit
f7146583e5
@ -105,13 +105,10 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
|
|||||||
{:base, to_charlist(base)},
|
{:base, to_charlist(base)},
|
||||||
{:filter, :eldap.equalityMatch(to_charlist(uid), to_charlist(name))},
|
{:filter, :eldap.equalityMatch(to_charlist(uid), to_charlist(name))},
|
||||||
{:scope, :eldap.wholeSubtree()},
|
{:scope, :eldap.wholeSubtree()},
|
||||||
{:attributes, ['mail', 'email']},
|
|
||||||
{:timeout, @search_timeout}
|
{:timeout, @search_timeout}
|
||||||
]) do
|
]) do
|
||||||
{:ok, {:eldap_search_result, [{:eldap_entry, _, attributes}], _}} ->
|
{:ok, {:eldap_search_result, [{:eldap_entry, _, _}], _}} ->
|
||||||
with {_, [mail]} <- List.keyfind(attributes, 'mail', 0) do
|
|
||||||
params = %{
|
params = %{
|
||||||
email: :erlang.list_to_binary(mail),
|
|
||||||
name: name,
|
name: name,
|
||||||
nickname: name,
|
nickname: name,
|
||||||
password: password,
|
password: password,
|
||||||
@ -124,11 +121,6 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
|
|||||||
{:ok, user} -> user
|
{:ok, user} -> user
|
||||||
error -> error
|
error -> error
|
||||||
end
|
end
|
||||||
else
|
|
||||||
_ ->
|
|
||||||
Logger.error("Could not find LDAP attribute mail: #{inspect(attributes)}")
|
|
||||||
{:error, :ldap_registration_missing_attributes}
|
|
||||||
end
|
|
||||||
|
|
||||||
error ->
|
error ->
|
||||||
error
|
error
|
||||||
|
@ -72,9 +72,7 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do
|
|||||||
equalityMatch: fn _type, _value -> :ok end,
|
equalityMatch: fn _type, _value -> :ok end,
|
||||||
wholeSubtree: fn -> :ok end,
|
wholeSubtree: fn -> :ok end,
|
||||||
search: fn _connection, _options ->
|
search: fn _connection, _options ->
|
||||||
{:ok,
|
{:ok, {:eldap_search_result, [{:eldap_entry, '', []}], []}}
|
||||||
{:eldap_search_result, [{:eldap_entry, '', [{'mail', [to_charlist(user.email)]}]}],
|
|
||||||
[]}}
|
|
||||||
end,
|
end,
|
||||||
close: fn _connection ->
|
close: fn _connection ->
|
||||||
send(self(), :close_connection)
|
send(self(), :close_connection)
|
||||||
|
Loading…
Reference in New Issue
Block a user