Add email to user account only if it exists in LDAP
This commit is contained in:
parent
2192d1e492
commit
81126b0142
2 changed files with 16 additions and 1 deletions
|
|
@ -103,13 +103,19 @@ defmodule Pleroma.Web.Auth.LDAPAuthenticator do
|
|||
{:scope, :eldap.wholeSubtree()},
|
||||
{:timeout, @search_timeout}
|
||||
]) do
|
||||
{:ok, {:eldap_search_result, [{:eldap_entry, _, _}], _}} ->
|
||||
{:ok, {:eldap_search_result, [{:eldap_entry, _, attributes}], _}} ->
|
||||
params = %{
|
||||
name: name,
|
||||
nickname: name,
|
||||
password: nil
|
||||
}
|
||||
|
||||
params =
|
||||
case List.keyfind(attributes, 'mail', 0) do
|
||||
{_, [mail]} -> Map.put_new(params, :email, :erlang.list_to_binary(mail))
|
||||
_ -> params
|
||||
end
|
||||
|
||||
changeset = User.register_changeset(%User{}, params)
|
||||
|
||||
case User.register(changeset) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue