-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Return 422 status when login fails + treat turbo_stream
as a navigational format
#5340
Changes from all commits
3b2d9ae
5f9c33e
91b3494
eef20a3
b9b793c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -77,7 +77,7 @@ def respond_to_on_destroy | |||
# support returning empty response on GET request | ||||
respond_to do |format| | ||||
format.all { head :no_content } | ||||
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) } | ||||
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name), status: :see_other } | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: responders now has a configuration This status is also going to be necessary on the registrations controller destroy action:
|
||||
end | ||||
end | ||||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,9 @@ def recall | |
end | ||
|
||
flash.now[:alert] = i18n_message(:invalid) if is_flashing_format? | ||
self.response = recall_app(warden_options[:recall]).call(request.env) | ||
response_from_app = recall_app(warden_options[:recall]).call(request.env) | ||
response_from_app[0] = recall_response_code(response_from_app[0]) | ||
self.response = response_from_app | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 this is kind of what I had in mind too, change the status code here for failed login attempts. I thought we could use responders though since we now have this configured there, so I went with that. This way, it can be overridden across the board and not only for this particular response. |
||
end | ||
|
||
def redirect | ||
|
@@ -89,6 +91,10 @@ def redirect | |
|
||
protected | ||
|
||
def recall_response_code(_original_response_code) | ||
422 | ||
end | ||
|
||
def i18n_options(options) | ||
options | ||
end | ||
|
@@ -167,7 +173,7 @@ def scope_url | |
end | ||
|
||
def skip_format? | ||
%w(html */*).include? request_format.to_s | ||
%w(html turbo_stream */*).include? request_format.to_s | ||
end | ||
|
||
# Choose whether we should respond in an HTTP authentication fashion, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were you having any issue with responders alone here, to have to enforce a status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@baarkerlounger made that change in ghiculescu@eef20a3
The discussion is here #5340 (comment), I don't really remember any context beyond that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, thanks. I think those should be handled by default with responders now 👍