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

fix(session#new): fix unhandled 500 when logging in with valid user and bad password #254

Conversation

mathemagica
Copy link

When token rotation is disabled, and the devise @resource is accessed within a before_filter, incorrect login credentials for an existing account can fail ungracefully causing a 500 server error instead of the expected 401. This is because both the @resource and @client_id remain set, despite falling through the failure criteria in set_user_by_token. As these instance variables persist, they allow the after_filter update_auth_header to continue to execute unexpectedly, calling auth_header = @resource.build_auth_header(@token, @client_id). This then triggers a null-ref in build_auth_header.

… caused by logging in with valid user, bad password, and DeviseTokenAuth.change_headers_on_each_request = false
@booleanbetrayal
Copy link
Collaborator

@lynndylanhurley - this was a crazy dive and probably not encountered by most people due to our disabling of the default token rotation and our use of before_filters that check current_user. Please let us know if you have any questions!

@barillax
Copy link

👍 tricky bug!

booleanbetrayal added a commit that referenced this pull request Jun 16, 2015
fix(session#new): fix unhandled 500 when logging in with valid user and bad password
@booleanbetrayal booleanbetrayal merged commit 3348d50 into lynndylanhurley:master Jun 16, 2015
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

Successfully merging this pull request may close these issues.

3 participants