Skip to content

Please provide meaningful error message if user is not found #51

Description

@paulepanter

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions