solidusio / solidus_auth_devise

🔑 Devise authentication for your Solidus store.
http://solidus.io
BSD 3-Clause "New" or "Revised" License
53 stars 128 forks source link

Non compatible with Turbo #218

Open jakemumu opened 2 years ago

jakemumu commented 2 years ago

Turbo requires redirects on form submissions, or in the case on render :new when login fails, the status on unprocessable_entity as the response code.

Is it possible to update this in this gem?

jarednorman commented 2 years ago

Can you explain a little more what needs to be changed to support Turbo? Is it default devise behaviour or custom stuff in this extension that might need to be updated to add support?

jakemumu commented 2 years ago

Apologies I really need to turn notifications on here -- sure, so basically, when Turbo is enabled and a form is submitted, the form needs to redirect or else Turbo won't re-render the page, there is a lot of information about it over the Hotwire GitHub.

The quick patch is to just change a couple methods in the user controllers:

When things are successful the controllers redirect and are fine, but currently when a failure happens: render :new is called, simply changing this to render :new, status: :unprocessable_entity fixes compatibility with Turbo.

That's in both the user sessions controller, and the user registrations controller.

jakemumu commented 2 years ago

Some relevant issues:

https://github.com/hotwired/turbo-rails/issues/122 https://github.com/heartcombo/devise/pull/5340 https://github.com/rails/rails/pull/41026