Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
ldap: don't crash on search when guessing an email
Browse files Browse the repository at this point in the history
The `search` method from Net::LDAP might return nil. In this case simply
return early as we do on other cases.

See #1832

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed May 28, 2018
1 parent 45814ba commit 93df51c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/portus/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def guess_email
return nil if cfg.nil? || !cfg["enabled"]

record = @ldap.search(search_options)
return nil if record.size != 1
return nil if record.blank? || record.size != 1
record = record.first

cfg["attr"].empty? ? guess_from_dn(record["dn"]) : guess_from_attr(record, cfg["attr"])
Expand Down

0 comments on commit 93df51c

Please sign in to comment.