Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
paulepanter opened this issue Mar 10, 2014 · 1 comment
Open

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

paulepanter opened this issue Mar 10, 2014 · 1 comment
Assignees

Comments

@paulepanter
Copy link

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.

@Arcath Arcath self-assigned this Mar 10, 2014
@Arcath
Copy link
Owner

Arcath commented Mar 26, 2014

this code only gets run if the user successfully authenticates which can only happen if the user exists.

As for better errors LDAP gives the same error for any kind of failed login be it wrong password, user that doesn't exist etc... so Adauth would then need to perform extra queries to check if the username you entered exists.

The login/sessions controller/views are supplied to help get you up and running quickly, if you want more functionality out of it then you will need to code that yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants