Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

DoubleRender errors caused by authenticate_or_request_with_http_basic #10508

Closed
shyam-habarakada opened this Issue · 2 comments

2 participants

@shyam-habarakada

I ran into my controllers throwing double render errors while using authenticate_or_request_with_http_basic. The issue appeared to be that the authenticate_or_request_with_http_basic method does not return (exit) the current action flow, and falls through to other render logic in the controller.

A discussion on stack overflow pointed out that you could stick the authentication logic in a before_filter, to work around this issue, and that worked for me. However, I'm wondering if there is an improvement to be made here -- especially since I wanted a few hours trying to figure out what was going on and it could help others avoid it.

The current implementation has this code, which does not appear to properly return from the controller action, and would allow it to fall through to other code in the controller block.
https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/http_authentication.rb#L113

Am I getting this right?

If yes, what can we do to fix this?

@laurocaetano
Collaborator

@shyam-habarakada I think this is the expected behavior, since it is documented here. It seems it does the same as your solution on the SO thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.