Skip to content
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

Incompatible with devise because route helpers include configuration #11

Open
technicalpickles opened this issue Feb 17, 2023 · 0 comments

Comments

@technicalpickles
Copy link

We've been using this gem for awhile, and at some point noticed that in development, the first request to need an authetnicated session would always fail with Warden::NotAuthenticated (:default user is not logged in). We traced this back to Devise not configuring warden until the routes are finalized: https://github.com/heartcombo/devise/blob/43800b4b8550d1249ab049a94ee7c16e243551a1/lib/devise/rails/routes.rb#L9-L23

module Devise
  module RouteSet
    def finalize!
      result = super
      @devise_finalized ||= begin
        if Devise.router_name.nil? && defined?(@devise_finalized) && self != Rails.application.try(:routes)
          warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
            "In this case, you probably want to set Devise.router_name = MOUNT_POINT, where "   \
            "MOUNT_POINT is a symbol representing where this engine will be mounted at. For "   \
            "now Devise will default the mount point to :main_app. You can explicitly set it"   \
            " to :main_app as well in case you want to keep the current behavior."
        end

        Devise.configure_warden!
        Devise.regenerate_helpers!
        true
      end
      result
    end
  end
end

We confirmed that disabling this gem fixed the problem. I suspect there are other gems that could be affected which have configuration done in route helpers... activeadmin comes to mind as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant