heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
24k stars 5.55k forks source link

DisabledSessionError on Registration. #5473

Open bnjtgly opened 2 years ago

bnjtgly commented 2 years ago

Environment

Current behavior

Prior to the issue, I have a Rails 6.1.4 API only app and the devise is perfectly fine. After I upgraded to Rails 7.0.2 the registrations_controller causes an error now. I appreciate your help. Thank you.

Getting the following error on a rails API only app's registrations_controller.rb. "exception": "#<ActionDispatch::Request::Session::DisabledSessionError: Your application has sessions disabled. To write to the session you must first configure a session store>"

Expected behavior

Registration should be successful. As everything works perfectly before I upgraded to 7.0.2.

tomshy commented 2 years ago

Experiencing this too. Respective versions as stated in the original issue

leonardobotrel commented 2 years ago

Same here. Rails -v 7.0.2.3

bnjtgly commented 2 years ago

Fixed this by using this temporary solution.

controller/concerns/rack_session_fix.rb

module RackSessionFix
  extend ActiveSupport::Concern
  class FakeRackSession < Hash
    def enabled?
      false
    end
  end
  included do
    before_action :set_fake_rack_session_for_devise
    private
    def set_fake_rack_session_for_devise
      request.env['rack.session'] ||= FakeRackSession.new
    end
  end
end

controller/registrations_controller.rb

class RegistrationsController < Devise::RegistrationsController
include RackSessionFix
...
end
e-serranor commented 1 year ago

Still happening, using versions: