solidusio / solidus_auth_devise

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

Adding omniauthable to to Spree::User #98

Closed Draiken closed 7 years ago

Draiken commented 7 years ago

Hi everyone, I've been having a few issues after adding omniauthable to the Spree::User class.

I used a module to prepend calls to devise and add any necessary extra methods, the problem happens on development when classes are reloaded.

I believe (haven't checked yet) that routes are reloaded before the core classes, so as soon as my routes file is read, it will setup the omniauthable routes, and load the Spree::User class but without my prepended module. This causes every class reload on development require a full server restart.

I tried solving this by creating a ::User class, inherit from Spree::User and setting Spree.user_class = "::User" but apparently constantize thinks that means Spree::User :(

One thing that could help would be a hook to add extra parameters to the devise call, which would then correctly load omniauthable even before my prepended modules.

What do you guys think? Am I doing some glaring stupid mistake?

mamhoff commented 7 years ago

No, you're running into a difficult problem that, fortunately, has been solved in another extension. Check the solidus_social gem, maybe you're only one gem away from a solution to your issue.

Draiken commented 7 years ago

Thanks! I'll check that out.

Meanwhile if anyone else encounters this, my solution is working: I added the module prepend to the routes file, forcing the Spree::User to be auto loaded and prepend my additional methods before the routes are evaluated. Development reloading is working perfectly now.

bbuchalter commented 7 years ago

I added the module prepend to the routes file, forcing the Spree::User to be auto loaded

I'm glad you got a working solution, but I'd wouldn't want to see the community adopting this strategy broadly. Adding my opinion for the record.

Draiken commented 7 years ago

Which is why I opened this issue in the first place :) If the devise modules that Spree::User sets were configurable, simply adding :omniauthable to that would suffice for the route generation.