-
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
Apply changes for rails-ujs and Turbo compatibility #5545
Changes from all commits
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 |
---|---|---|
|
@@ -38,6 +38,6 @@ | |
|
||
<h3>Cancel my account</h3> | ||
|
||
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p> | ||
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></p> | ||
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 looks like a good option to support both confirm options. |
||
|
||
<%= link_to "Back", :back %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,6 @@ | |
|
||
<%- if devise_mapping.omniauthable? %> | ||
<%- resource_class.omniauth_providers.each do |provider| %> | ||
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post %><br /> | ||
<%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %><br /> | ||
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. Yeah, I think the best option for this one might be a button since this is not something that should go through turbo I guess? The only other option that could work would be two methods. ( 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. As far as I tested, Turbo didn't work with OAuth because it raises CORS error. Here is the result when I click the link generated via So I had to change this line from link to button and add 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. Good point, I hadn't thought about CORS but yeah since it's all happening via JS it will trigger a CORS error when trying to follow the redirect with fetch under the hood.
|
||
<% end %> | ||
<% end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ def respond | |
if http_auth? | ||
http_auth | ||
elsif warden_options[:recall] | ||
recall | ||
request_format == :turbo_stream ? redirect : recall | ||
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. I am afraid that while redirecting works in the sense that it will re-display the form as expected, it will lose some context about the flash / error message and show the more generic "you need to be signed in" instead of the "invalid email or password". Ideally we'd still recall, but change the status, so it has that same behavior. |
||
else | ||
redirect | ||
end | ||
|
@@ -167,7 +167,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, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ def reset_password(options = {}, &block) | |
fill_in 'email', with: '[email protected]' | ||
end | ||
|
||
assert_response :success | ||
assert_response :unprocessable_entity | ||
assert_current_url '/users/password' | ||
assert_have_selector "input[type=email][value='[email protected]']" | ||
assert_contain 'not found' | ||
|
@@ -102,7 +102,7 @@ def reset_password(options = {}, &block) | |
fill_in 'email', with: ' [email protected] ' | ||
end | ||
|
||
assert_response :success | ||
assert_response :unprocessable_entity | ||
assert_current_url '/users/password' | ||
assert_have_selector "input[type=email][value=' [email protected] ']" | ||
assert_contain 'not found' | ||
|
@@ -132,7 +132,7 @@ def reset_password(options = {}, &block) | |
fill_in 'email', with: '[email protected]' | ||
end | ||
|
||
assert_response :success | ||
assert_response :unprocessable_entity | ||
assert_current_url '/users/password' | ||
assert_have_selector "input[type=email][value='[email protected]']" | ||
assert_contain 'not found' | ||
|
@@ -156,7 +156,7 @@ def reset_password(options = {}, &block) | |
user = create_user | ||
reset_password reset_password_token: 'invalid_reset_password' | ||
|
||
assert_response :success | ||
assert_response :unprocessable_entity | ||
assert_current_url '/users/password' | ||
assert_have_selector '#error_explanation' | ||
assert_contain %r{Reset password token(.*)invalid} | ||
|
@@ -170,7 +170,7 @@ def reset_password(options = {}, &block) | |
fill_in 'Confirm new password', with: 'other_password' | ||
end | ||
|
||
assert_response :success | ||
assert_response :unprocessable_entity | ||
assert_current_url '/users/password' | ||
assert_have_selector '#error_explanation' | ||
assert_contain "Password confirmation doesn't match Password" | ||
|
@@ -192,7 +192,7 @@ def reset_password(options = {}, &block) | |
request_forgot_password | ||
|
||
reset_password { fill_in 'Confirm new password', with: 'other_password' } | ||
assert_response :success | ||
assert_response :unprocessable_entity | ||
assert_have_selector '#error_explanation' | ||
refute user.reload.valid_password?('987654321') | ||
|
||
|
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.
Note: We will be able to use responders to handle this for us across the board going forward.
Please see https://github.com/heartcombo/responders/blob/fb9f787055a7a842584ce351793b249676290090/CHANGELOG.md#unreleased (still unreleased at the time of this writing)