-
Notifications
You must be signed in to change notification settings - Fork 433
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
Devise github login not working after Turbo enabled. #45
Comments
Is this related to hotwired/turbo-rails#33? |
Hi @seanpdoyle, thanks for the reply! I think they do are related. But after I tried changing
I noticed that the |
Here's what I did to get it working. I added a FailureApp to handle Warden auth failures and a custom responder. Both of those are needed to treat turbo_stream formats like html. The latest Turbo will handle the 422 status for errors to correctly update the DOM without adding any turbo_stream views. # config/initializers/devise.rb
# frozen_string_literal: true
class TurboFailureApp < Devise::FailureApp
def respond
if request_format == :turbo_stream
redirect
else
super
end
end
def skip_format?
%w(html turbo_stream */*).include? request_format.to_s
end
end
class TurboController < ApplicationController
class Responder < ActionController::Responder
def to_turbo_stream
controller.render(options.merge(formats: :html))
rescue ActionView::MissingTemplate => error
if get?
raise error
elsif has_errors? && default_action
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
else
redirect_to navigation_location
end
end
end
self.responder = Responder
respond_to :html, :turbo_stream
end
Devise.setup do |config|
# ==> Controller configuration
# Configure the parent class to the devise controllers.
config.parent_controller = 'TurboController'
# ==> Warden configuration
config.warden do |manager|
manager.failure_app = TurboFailureApp
end
end Screencast on how it all works: https://gorails.com/episodes/devise-hotwire-turbo?autoplay=1 |
Hi Chris @excid3 , thank you for your response! Now that #3 has been merged, I think another way to fix this is by simply adding |
Closing this now that Turbo 7.0.0-beta.2 is out. |
Addresses: #842 The bug existed in _sign-in_, _sign-up_, and _users/edit_ page. You can view it in the attached video below. https://user-images.githubusercontent.com/25191509/176618871-e3e9c2b5-b6bd-4dfb-a59b-80e9ccfecf0b.mp4 The following reference is used to patch this bug. [https://github.com/hotwired/turbo/issues/45](https://github.com/hotwired/turbo/issues/45) And, below is the demo video after the fix. https://user-images.githubusercontent.com/25191509/176619214-bf10ce2c-60be-44ce-bfe8-ed97c9930dff.mp4 ## fix for action text not loading in production / staging Reference: rails/rails#37672 Addresses: #852 Co-authored-by: Prashant <[email protected]>
@0q2 the latest version of Devise fixes this, so there is no need for the work-around anymore. |
You are correct! |
I'm using Devise GitHub omniauth login for an app and the login link looks like this:
After I enable Turbo, it no longer works. After inspecting the network, I found that when a user clicks on the link, it issues a
fetch
type request to the server, rather then adocument
type request.My app is open-sourced here and you can reproduce it by uncommenting the
// import { Turbo, cable } from '@hotwired/turbo-rails'
line from application.js pack file.The text was updated successfully, but these errors were encountered: