In lib/adauth/authenticate.rb the code below is going to result in a “crash” when the search result is empty.
user = Adauth::AdObjects::User.where('sAMAccountName', username).first
if allowed_to_login(user)
Adauth.logger.info("authentication") { "Authentication succesful" }
return user
else
Adauth.logger.info("authentication") { "Authentication failed (not in allowed group or ou)" }
return false
end
Calling the method first on the empty result, results in user being nil, which causes failures further down the path. Could a check be added, so that false is returned if user is nil.
Even better would be to return more error codes or even messages, which can then be displayed in the log-in dialog.
In
lib/adauth/authenticate.rbthe code below is going to result in a “crash” when the search result is empty.Calling the method
firston the empty result, results in user beingnil, which causes failures further down the path. Could a check be added, so thatfalseis returned ifuserisnil.Even better would be to return more error codes or even messages, which can then be displayed in the log-in dialog.